GCMサーバーの修正バージョンをコンパイルしたい。
しかし、私は説明できないエラーが発生しています。
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.gcm.demo.server;
import com.google.android.gcm.server.Constants;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.MulticastResult;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet that adds a new message to all registered devices.
* <p>
* This servlet is used just by the browser (i.e., not device).
*/
@SuppressWarnings("serial")
public class SendAllMessagesServlet extends BaseServlet {
private static final int MULTICAST_SIZE = 1000;
private Sender sender;
private static final Executor threadPool = Executors.newFixedThreadPool(5);
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
sender = newSender(config);
}
/**
* Creates the {@link Sender} based on the servlet settings.
*/
protected Sender newSender(ServletConfig config) {
String key = (String) config.getServletContext()
.getAttribute(ApiKeyInitializer.ATTRIBUTE_ACCESS_KEY);
return new Sender(key);
}
/**
* Processes the request to add a new message.
*/
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
List<String> devices = Datastore.getDevices();
String status;
if (devices.isEmpty()) {
status = "Message ignored as there is no device registered!";
} else {
// NOTE: check below is for demonstration purposes; a real application
// could always send a multicast, even for just one recipient
if (devices.size() == 1) {
// send a single message using plain post
String registrationId = devices.get(0);
Message message = new Message.Builder();
//MY LANES
message.setData("echo", req.getAttribute("message").toString());
message.build();
//END
Result result = sender.send(message, registrationId, 5);
status = "Sent message to one device: " + result;
} else {
// send a multicast message using JSON
// must split in chunks of 1000 devices (GCM limit)
int total = devices.size();
List<String> partialDevices = new ArrayList<String>(total);
int counter = 0;
int tasks = 0;
for (String device : devices) {
counter++;
partialDevices.add(device);
int partialSize = partialDevices.size();
if (partialSize == MULTICAST_SIZE || counter == total) {
msg = req.getAttribute("message");
asyncSend(partialDevices);
partialDevices.clear();
tasks++;
}
}
status = "Asynchronously sending " + tasks + " multicast messages to " +
total + " devices";
}
}
req.setAttribute(HomeServlet.ATTRIBUTE_STATUS, status.toString());
getServletContext().getRequestDispatcher("/home").forward(req, resp);
}
public String msg = "";
private void asyncSend(List<String> partialDevices) {
// make a copy
final List<String> devices = new ArrayList<String>(partialDevices);
threadPool.execute(new Runnable() {
public void run() {
Message message = new Message.Builder();
//MY LANES
message.setData("echo", msg);
message.build();
//END
MulticastResult multicastResult;
try {
multicastResult = sender.send(message, devices, 5);
} catch (IOException e) {
logger.log(Level.SEVERE, "Error posting messages", e);
return;
}
List<Result> results = multicastResult.getResults();
// analyze the results
for (int i = 0; i < devices.size(); i++) {
String regId = devices.get(i);
Result result = results.get(i);
String messageId = result.getMessageId();
if (messageId != null) {
logger.fine("Succesfully sent message to device: " + regId +
"; messageId = " + messageId);
String canonicalRegId = result.getCanonicalRegistrationId();
if (canonicalRegId != null) {
// same device has more than on registration id: update it
logger.info("canonicalRegId " + canonicalRegId);
Datastore.updateRegistration(regId, canonicalRegId);
}
} else {
String error = result.getErrorCodeName();
if (error.equals(Constants.ERROR_NOT_REGISTERED)) {
// application has been removed from device - unregister it
logger.info("Unregistered device: " + regId);
Datastore.unregister(regId);
} else {
logger.severe("Error sending message to " + regId + ": " + error);
}
}
}
}});
}
}
コンパイラの応答は次のとおりです。
C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gcm-demo-serve
r>"C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\apache-ant-
1.8.4\bin\ant" war
Buildfile: C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gcm
-demo-server\build.xml
init:
compile:
[javac] Compiling 1 source file to C:\Users\Sebastian Reuther\android-sdks\e
xtras\google\gcm\samples\gcm-demo-server\build\classes
[javac]
[javac] WARNING
[javac]
[javac] The -source switch defaults to 1.7 in JDK 1.7.
[javac] If you specify -target 1.5 you now must also specify -source 1.5.
[javac] Ant will implicitly add -source 1.5 for you. Please change your bui
ld file.
[javac] warning: java\io\IOException.class(java\io:IOException.class): major
version 51 is newer than 50, the highest major version supported by this compil
er.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\ArrayList.class(java\util:ArrayList.class): major
version 51 is newer than 50, the highest major version supported by this compil
er.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\List.class(java\util:List.class): major version 5
1 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\concurrent\Executor.class(java\util\concurrent:Ex
ecutor.class): major version 51 is newer than 50, the highest major version supp
orted by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\concurrent\Executors.class(java\util\concurrent:E
xecutors.class): major version 51 is newer than 50, the highest major version su
pported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\logging\Level.class(java\util\logging:Level.class
): major version 51 is newer than 50, the highest major version supported by thi
s compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\io\Serializable.class(java\io:Serializable.class): maj
or version 51 is newer than 50, the highest major version supported by this comp
iler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Object.class(java\lang:Object.class): major versi
on 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\SuppressWarnings.class(java\lang:SuppressWarnings
.class): major version 51 is newer than 50, the highest major version supported
by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\String.class(java\lang:String.class): major versi
on 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\annotation\Target.class(java\lang\annotation:Targ
et.class): major version 51 is newer than 50, the highest major version supporte
d by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\annotation\ElementType.class(java\lang\annotation
:ElementType.class): major version 51 is newer than 50, the highest major versio
n supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\annotation\Retention.class(java\lang\annotation:R
etention.class): major version 51 is newer than 50, the highest major version su
pported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\annotation\RetentionPolicy.class(java\lang\annota
tion:RetentionPolicy.class): major version 51 is newer than 50, the highest majo
r version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\annotation\Annotation.class(java\lang\annotation:
Annotation.class): major version 51 is newer than 50, the highest major version
supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Override.class(java\lang:Override.class): major v
ersion 51 is newer than 50, the highest major version supported by this compiler
.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Error.class(java\lang:Error.class): major version
51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Exception.class(java\lang:Exception.class): major
version 51 is newer than 50, the highest major version supported by this compil
er.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Throwable.class(java\lang:Throwable.class): major
version 51 is newer than 50, the highest major version supported by this compil
er.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\RuntimeException.class(java\lang:RuntimeException
.class): major version 51 is newer than 50, the highest major version supported
by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\concurrent\ExecutorService.class(java\util\concur
rent:ExecutorService.class): major version 51 is newer than 50, the highest majo
r version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\Collection.class(java\util:Collection.class): maj
or version 51 is newer than 50, the highest major version supported by this comp
iler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Iterable.class(java\lang:Iterable.class): major v
ersion 51 is newer than 50, the highest major version supported by this compiler
.
[javac] It is recommended that the compiler be upgraded.
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:81: incompatible types
[javac] found : com.google.android.gcm.server.Message.Builder
[javac] required: com.google.android.gcm.server.Message
[javac] Message message = new Message.Builder();
[javac] ^
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:82: cannot find symbol
[javac] symbol : method setData(java.lang.String,java.lang.String)
[javac] location: class com.google.android.gcm.server.Message
[javac] message.setData("echo", req.getAttribute("message").toString
());
[javac] ^
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:83: cannot find symbol
[javac] symbol : method build()
[javac] location: class com.google.android.gcm.server.Message
[javac] message.build();
[javac] ^
[javac] warning: java\lang\Comparable.class(java\lang:Comparable.class): maj
or version 51 is newer than 50, the highest major version supported by this comp
iler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\CharSequence.class(java\lang:CharSequence.class):
major version 51 is newer than 50, the highest major version supported by this
compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\AbstractList.class(java\util:AbstractList.class):
major version 51 is newer than 50, the highest major version supported by this
compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\AbstractCollection.class(java\util:AbstractCollec
tion.class): major version 51 is newer than 50, the highest major version suppor
ted by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:99: incompatible types
[javac] found : java.lang.Object
[javac] required: java.lang.String
[javac] msg = req.getAttribute("message");
[javac] ^
[javac] warning: java\lang\Runnable.class(java\lang:Runnable.class): major v
ersion 51 is newer than 50, the highest major version supported by this compiler
.
[javac] It is recommended that the compiler be upgraded.
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:121: incompatible types
[javac] found : com.google.android.gcm.server.Message.Builder
[javac] required: com.google.android.gcm.server.Message
[javac] Message message = new Message.Builder();
[javac] ^
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:122: cannot find symbol
[javac] symbol : method setData(java.lang.String,java.lang.String)
[javac] location: class com.google.android.gcm.server.Message
[javac] message.setData("echo", msg);
[javac] ^
[javac] C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gc
m-demo-server\src\com\google\android\gcm\demo\server\SendAllMessagesServlet.java
:123: cannot find symbol
[javac] symbol : method build()
[javac] location: class com.google.android.gcm.server.Message
[javac] message.build();
[javac] ^
[javac] warning: java\util\logging\Logger.class(java\util\logging:Logger.cla
ss): major version 51 is newer than 50, the highest major version supported by t
his compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\logging\LogRecord.class(java\util\logging:LogReco
rd.class): major version 51 is newer than 50, the highest major version supporte
d by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] 7 errors
[javac] 30 warnings
BUILD FAILED
C:\Users\Sebastian Reuther\android-sdks\extras\google\gcm\samples\gcm-demo-serve
r\build.xml:52: Compile failed; see the compiler error output for details.
Total time: 0 seconds
何かアイデアは何が間違っていますか?