repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
liuguangqiang/Idaily | app/src/main/java/com/liuguangqiang/idaily/utils/databinding/DataBindingAdapter.java | // Path: app/src/main/java/com/liuguangqiang/idaily/widget/MyWebView.java
// public class MyWebView extends WebView {
//
// public MyWebView(Context context) {
// this(context, null);
// }
//
// public MyWebView(Context context, AttributeSet attrs) {
// super(context, attrs, 0);
// }
//
// public MyWebView(Context context, AttributeSet attrs, int defStyle) {
// super(context, attrs, defStyle);
// }
//
// @Override
// protected void onScrollChanged(int l, int t, int oldl, int oldt) {
// super.onScrollChanged(l, t, oldl, oldt);
// Logs.i("t:" + t);
// }
//
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/utils/DailyUtils.java
// public class DailyUtils {
//
// private DailyUtils() {
// }
//
// public static String getDisplayDate(Context context, int datetime) {
// String[] weekTitle = context.getResources().getStringArray(R.array.weeks);
//
// int year = datetime / 10000;
// int month = (datetime % 10000) / 100 - 1;
// int day = datetime % 100;
// Date date = new GregorianCalendar(year, month, day).getTime();
//
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int week = calendar.get(calendar.DAY_OF_WEEK);
//
// return TimeUtils.convertByFormatter(date, "MM月dd日") + " " + weekTitle[week - 1];
// }
//
// }
| import androidx.databinding.BindingAdapter;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.liuguangqiang.idaily.widget.MyWebView;
import com.liuguangqiang.idaily.utils.DailyUtils; | package com.liuguangqiang.idaily.utils.databinding;
/**
* Custom binding.
* <p>
* Created by Eric on 15/6/23.
*/
public class DataBindingAdapter {
@BindingAdapter({"imageUrl"})
public static void loadImage(ImageView iv, String imageUrl) {
if (!TextUtils.isEmpty(imageUrl))
Glide.with(iv.getContext()).load(imageUrl).into(iv);
}
@BindingAdapter({"body"}) | // Path: app/src/main/java/com/liuguangqiang/idaily/widget/MyWebView.java
// public class MyWebView extends WebView {
//
// public MyWebView(Context context) {
// this(context, null);
// }
//
// public MyWebView(Context context, AttributeSet attrs) {
// super(context, attrs, 0);
// }
//
// public MyWebView(Context context, AttributeSet attrs, int defStyle) {
// super(context, attrs, defStyle);
// }
//
// @Override
// protected void onScrollChanged(int l, int t, int oldl, int oldt) {
// super.onScrollChanged(l, t, oldl, oldt);
// Logs.i("t:" + t);
// }
//
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/utils/DailyUtils.java
// public class DailyUtils {
//
// private DailyUtils() {
// }
//
// public static String getDisplayDate(Context context, int datetime) {
// String[] weekTitle = context.getResources().getStringArray(R.array.weeks);
//
// int year = datetime / 10000;
// int month = (datetime % 10000) / 100 - 1;
// int day = datetime % 100;
// Date date = new GregorianCalendar(year, month, day).getTime();
//
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int week = calendar.get(calendar.DAY_OF_WEEK);
//
// return TimeUtils.convertByFormatter(date, "MM月dd日") + " " + weekTitle[week - 1];
// }
//
// }
// Path: app/src/main/java/com/liuguangqiang/idaily/utils/databinding/DataBindingAdapter.java
import androidx.databinding.BindingAdapter;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.liuguangqiang.idaily.widget.MyWebView;
import com.liuguangqiang.idaily.utils.DailyUtils;
package com.liuguangqiang.idaily.utils.databinding;
/**
* Custom binding.
* <p>
* Created by Eric on 15/6/23.
*/
public class DataBindingAdapter {
@BindingAdapter({"imageUrl"})
public static void loadImage(ImageView iv, String imageUrl) {
if (!TextUtils.isEmpty(imageUrl))
Glide.with(iv.getContext()).load(imageUrl).into(iv);
}
@BindingAdapter({"body"}) | public static void loadBody(MyWebView webView, String body) { |
liuguangqiang/Idaily | app/src/main/java/com/liuguangqiang/idaily/utils/databinding/DataBindingAdapter.java | // Path: app/src/main/java/com/liuguangqiang/idaily/widget/MyWebView.java
// public class MyWebView extends WebView {
//
// public MyWebView(Context context) {
// this(context, null);
// }
//
// public MyWebView(Context context, AttributeSet attrs) {
// super(context, attrs, 0);
// }
//
// public MyWebView(Context context, AttributeSet attrs, int defStyle) {
// super(context, attrs, defStyle);
// }
//
// @Override
// protected void onScrollChanged(int l, int t, int oldl, int oldt) {
// super.onScrollChanged(l, t, oldl, oldt);
// Logs.i("t:" + t);
// }
//
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/utils/DailyUtils.java
// public class DailyUtils {
//
// private DailyUtils() {
// }
//
// public static String getDisplayDate(Context context, int datetime) {
// String[] weekTitle = context.getResources().getStringArray(R.array.weeks);
//
// int year = datetime / 10000;
// int month = (datetime % 10000) / 100 - 1;
// int day = datetime % 100;
// Date date = new GregorianCalendar(year, month, day).getTime();
//
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int week = calendar.get(calendar.DAY_OF_WEEK);
//
// return TimeUtils.convertByFormatter(date, "MM月dd日") + " " + weekTitle[week - 1];
// }
//
// }
| import androidx.databinding.BindingAdapter;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.liuguangqiang.idaily.widget.MyWebView;
import com.liuguangqiang.idaily.utils.DailyUtils; | package com.liuguangqiang.idaily.utils.databinding;
/**
* Custom binding.
* <p>
* Created by Eric on 15/6/23.
*/
public class DataBindingAdapter {
@BindingAdapter({"imageUrl"})
public static void loadImage(ImageView iv, String imageUrl) {
if (!TextUtils.isEmpty(imageUrl))
Glide.with(iv.getContext()).load(imageUrl).into(iv);
}
@BindingAdapter({"body"})
public static void loadBody(MyWebView webView, String body) {
if (!TextUtils.isEmpty(body))
webView.loadData(body, "text/html; charset=UTF-8", null);
}
@BindingAdapter({"datetime"})
public static void loadDatetime(TextView textView, int datetime) { | // Path: app/src/main/java/com/liuguangqiang/idaily/widget/MyWebView.java
// public class MyWebView extends WebView {
//
// public MyWebView(Context context) {
// this(context, null);
// }
//
// public MyWebView(Context context, AttributeSet attrs) {
// super(context, attrs, 0);
// }
//
// public MyWebView(Context context, AttributeSet attrs, int defStyle) {
// super(context, attrs, defStyle);
// }
//
// @Override
// protected void onScrollChanged(int l, int t, int oldl, int oldt) {
// super.onScrollChanged(l, t, oldl, oldt);
// Logs.i("t:" + t);
// }
//
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/utils/DailyUtils.java
// public class DailyUtils {
//
// private DailyUtils() {
// }
//
// public static String getDisplayDate(Context context, int datetime) {
// String[] weekTitle = context.getResources().getStringArray(R.array.weeks);
//
// int year = datetime / 10000;
// int month = (datetime % 10000) / 100 - 1;
// int day = datetime % 100;
// Date date = new GregorianCalendar(year, month, day).getTime();
//
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int week = calendar.get(calendar.DAY_OF_WEEK);
//
// return TimeUtils.convertByFormatter(date, "MM月dd日") + " " + weekTitle[week - 1];
// }
//
// }
// Path: app/src/main/java/com/liuguangqiang/idaily/utils/databinding/DataBindingAdapter.java
import androidx.databinding.BindingAdapter;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.liuguangqiang.idaily.widget.MyWebView;
import com.liuguangqiang.idaily.utils.DailyUtils;
package com.liuguangqiang.idaily.utils.databinding;
/**
* Custom binding.
* <p>
* Created by Eric on 15/6/23.
*/
public class DataBindingAdapter {
@BindingAdapter({"imageUrl"})
public static void loadImage(ImageView iv, String imageUrl) {
if (!TextUtils.isEmpty(imageUrl))
Glide.with(iv.getContext()).load(imageUrl).into(iv);
}
@BindingAdapter({"body"})
public static void loadBody(MyWebView webView, String body) {
if (!TextUtils.isEmpty(body))
webView.loadData(body, "text/html; charset=UTF-8", null);
}
@BindingAdapter({"datetime"})
public static void loadDatetime(TextView textView, int datetime) { | textView.setText(DailyUtils.getDisplayDate(textView.getContext(), datetime)); |
liuguangqiang/Idaily | app/src/main/java/com/liuguangqiang/idaily/entity/StorySection.java | // Path: app/src/main/java/com/liuguangqiang/idaily/adapter/StoriesAdapter.java
// public class StoriesAdapter extends BaseProviderMultiAdapter<BaseEntity> implements LoadMoreModule {
//
// public static final int ITEM_STORY = 0;
//
// public static final int ITEM_SECTION = 1;
//
// public StoriesAdapter(@Nullable List<BaseEntity> data) {
// super(data);
// addItemProvider(new StoryItemProvider());
// addItemProvider(new SectionItemProvider());
// }
//
// @Override
// protected int getItemType(List<? extends BaseEntity> list, int i) {
// if (getItem(i) instanceof StorySection) {
// return ITEM_SECTION;
// }
// return ITEM_STORY;
// }
// }
| import com.liuguangqiang.idaily.adapter.StoriesAdapter; | package com.liuguangqiang.idaily.entity;
/**
* Created by Eric on 15/6/9.
*/
public class StorySection extends BaseEntity {
public int datetime;
public StorySection(int datetime) {
this.datetime = datetime;
}
@Override
public int getItemType() { | // Path: app/src/main/java/com/liuguangqiang/idaily/adapter/StoriesAdapter.java
// public class StoriesAdapter extends BaseProviderMultiAdapter<BaseEntity> implements LoadMoreModule {
//
// public static final int ITEM_STORY = 0;
//
// public static final int ITEM_SECTION = 1;
//
// public StoriesAdapter(@Nullable List<BaseEntity> data) {
// super(data);
// addItemProvider(new StoryItemProvider());
// addItemProvider(new SectionItemProvider());
// }
//
// @Override
// protected int getItemType(List<? extends BaseEntity> list, int i) {
// if (getItem(i) instanceof StorySection) {
// return ITEM_SECTION;
// }
// return ITEM_STORY;
// }
// }
// Path: app/src/main/java/com/liuguangqiang/idaily/entity/StorySection.java
import com.liuguangqiang.idaily.adapter.StoriesAdapter;
package com.liuguangqiang.idaily.entity;
/**
* Created by Eric on 15/6/9.
*/
public class StorySection extends BaseEntity {
public int datetime;
public StorySection(int datetime) {
this.datetime = datetime;
}
@Override
public int getItemType() { | return StoriesAdapter.ITEM_SECTION; |
liuguangqiang/Idaily | app/src/main/java/com/liuguangqiang/idaily/feature/detail/StoryActivity.java | // Path: app/src/main/java/com/liuguangqiang/idaily/entity/Story.java
// public class Story extends BaseEntity implements Parcelable {
//
// public int id;
//
// public String title;
//
// public int type = 0;
//
// public List<String> images = new ArrayList<>();
//
// public String image;
//
// public String body;
//
// public List<String> css;
//
// public String share_url;
//
// public String hint;
//
// public List<String> getCss() {
// return css;
// }
//
// public void setCss(List<String> css) {
// this.css = css;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getImage() {
// return image;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImages() {
// return images;
// }
//
// public void setImages(List<String> images) {
// this.images = images;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public Story() {
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// @Override
// public String toString() {
// return "Story{" +
// "id=" + id +
// ", title='" + title + '\'' +
// ", type=" + type +
// ", images=" + images +
// ", image='" + image + '\'' +
// ", body='" + body + '\'' +
// ", css=" + css +
// '}';
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(this.id);
// dest.writeString(this.title);
// dest.writeInt(this.type);
// dest.writeStringList(this.images);
// dest.writeString(this.image);
// dest.writeString(this.body);
// dest.writeStringList(this.css);
// dest.writeString(this.share_url);
// }
//
// protected Story(Parcel in) {
// this.id = in.readInt();
// this.title = in.readString();
// this.type = in.readInt();
// this.images = in.createStringArrayList();
// this.image = in.readString();
// this.body = in.readString();
// this.css = in.createStringArrayList();
// this.share_url = in.readString();
// }
//
// public static final Creator<Story> CREATOR = new Creator<Story>() {
// public Story createFromParcel(Parcel source) {
// return new Story(source);
// }
//
// public Story[] newArray(int size) {
// return new Story[size];
// }
// };
//
// @Override
// public int getItemType() {
// return StoriesAdapter.ITEM_STORY;
// }
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/app/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// onCreateBinding();
// }
//
// public abstract void onCreateBinding();
//
// public <T extends View> T findById(int resId) {
// return (T) findViewById(resId);
// }
//
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/adapter/WebViewAdapter.java
// public class WebViewAdapter extends BaseQuickAdapter<Story, BaseViewHolder> {
//
// public WebViewAdapter(@Nullable List<Story> data) {
// super(R.layout.item_webview, data);
// }
//
// @Override
// protected void convert(BaseViewHolder helper, Story item) {
// ItemWebviewBinding binding = ItemWebviewBinding.bind(helper.itemView);
// binding.webView.loadData(getBody(item), "text/html; charset=UTF-8", null);
// }
//
// public String getBody(Story story) {
// if (story == null) return "";
// return loadDataWithCSS(story.getBody(), story.getCss().get(0));
// }
//
// private String loadDataWithCSS(String loadData, String cssPath) {
// String header = "<html><head><link href=\"%s\" type=\"text/css\" rel=\"stylesheet\"/></head><body>";
// String footer = "</body></html>";
// StringBuilder sb = new StringBuilder();
// sb.append(String.format(header, cssPath));
// sb.append(loadData);
// sb.append(footer);
// return sb.toString();
// }
// }
| import android.graphics.Color;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.WindowManager;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout;
import com.liuguangqiang.idaily.R;
import com.liuguangqiang.idaily.databinding.ActivityStoryBinding;
import com.liuguangqiang.idaily.entity.Story;
import com.liuguangqiang.idaily.app.BaseActivity;
import com.liuguangqiang.idaily.adapter.WebViewAdapter;
import java.util.ArrayList;
import timber.log.Timber; | package com.liuguangqiang.idaily.feature.detail;
public class StoryActivity extends BaseActivity {
public static final String ARG_STORY = "ARG_STORY";
private StoryViewModel viewModel;
private ActivityStoryBinding binding; | // Path: app/src/main/java/com/liuguangqiang/idaily/entity/Story.java
// public class Story extends BaseEntity implements Parcelable {
//
// public int id;
//
// public String title;
//
// public int type = 0;
//
// public List<String> images = new ArrayList<>();
//
// public String image;
//
// public String body;
//
// public List<String> css;
//
// public String share_url;
//
// public String hint;
//
// public List<String> getCss() {
// return css;
// }
//
// public void setCss(List<String> css) {
// this.css = css;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getImage() {
// return image;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImages() {
// return images;
// }
//
// public void setImages(List<String> images) {
// this.images = images;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public Story() {
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// @Override
// public String toString() {
// return "Story{" +
// "id=" + id +
// ", title='" + title + '\'' +
// ", type=" + type +
// ", images=" + images +
// ", image='" + image + '\'' +
// ", body='" + body + '\'' +
// ", css=" + css +
// '}';
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(this.id);
// dest.writeString(this.title);
// dest.writeInt(this.type);
// dest.writeStringList(this.images);
// dest.writeString(this.image);
// dest.writeString(this.body);
// dest.writeStringList(this.css);
// dest.writeString(this.share_url);
// }
//
// protected Story(Parcel in) {
// this.id = in.readInt();
// this.title = in.readString();
// this.type = in.readInt();
// this.images = in.createStringArrayList();
// this.image = in.readString();
// this.body = in.readString();
// this.css = in.createStringArrayList();
// this.share_url = in.readString();
// }
//
// public static final Creator<Story> CREATOR = new Creator<Story>() {
// public Story createFromParcel(Parcel source) {
// return new Story(source);
// }
//
// public Story[] newArray(int size) {
// return new Story[size];
// }
// };
//
// @Override
// public int getItemType() {
// return StoriesAdapter.ITEM_STORY;
// }
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/app/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// onCreateBinding();
// }
//
// public abstract void onCreateBinding();
//
// public <T extends View> T findById(int resId) {
// return (T) findViewById(resId);
// }
//
// }
//
// Path: app/src/main/java/com/liuguangqiang/idaily/adapter/WebViewAdapter.java
// public class WebViewAdapter extends BaseQuickAdapter<Story, BaseViewHolder> {
//
// public WebViewAdapter(@Nullable List<Story> data) {
// super(R.layout.item_webview, data);
// }
//
// @Override
// protected void convert(BaseViewHolder helper, Story item) {
// ItemWebviewBinding binding = ItemWebviewBinding.bind(helper.itemView);
// binding.webView.loadData(getBody(item), "text/html; charset=UTF-8", null);
// }
//
// public String getBody(Story story) {
// if (story == null) return "";
// return loadDataWithCSS(story.getBody(), story.getCss().get(0));
// }
//
// private String loadDataWithCSS(String loadData, String cssPath) {
// String header = "<html><head><link href=\"%s\" type=\"text/css\" rel=\"stylesheet\"/></head><body>";
// String footer = "</body></html>";
// StringBuilder sb = new StringBuilder();
// sb.append(String.format(header, cssPath));
// sb.append(loadData);
// sb.append(footer);
// return sb.toString();
// }
// }
// Path: app/src/main/java/com/liuguangqiang/idaily/feature/detail/StoryActivity.java
import android.graphics.Color;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.WindowManager;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout;
import com.liuguangqiang.idaily.R;
import com.liuguangqiang.idaily.databinding.ActivityStoryBinding;
import com.liuguangqiang.idaily.entity.Story;
import com.liuguangqiang.idaily.app.BaseActivity;
import com.liuguangqiang.idaily.adapter.WebViewAdapter;
import java.util.ArrayList;
import timber.log.Timber;
package com.liuguangqiang.idaily.feature.detail;
public class StoryActivity extends BaseActivity {
public static final String ARG_STORY = "ARG_STORY";
private StoryViewModel viewModel;
private ActivityStoryBinding binding; | private WebViewAdapter adapter; |
liuguangqiang/Idaily | app/src/main/java/com/liuguangqiang/idaily/api/service/DailyService.java | // Path: app/src/main/java/com/liuguangqiang/idaily/entity/Daily.java
// public class Daily extends BaseEntity {
//
// private int id;
//
// private int date;
//
// private List<Story> stories;
//
// private List<Story> top_stories;
//
// public int getDate() {
// return date;
// }
//
// public void setDate(int date) {
// this.date = date;
// }
//
// public List<Story> getStories() {
// return stories;
// }
//
// public void setStories(List<Story> stories) {
// this.stories = stories;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public List<Story> getTop_stories() {
// return top_stories;
// }
//
// public void setTop_stories(List<Story> top_stories) {
// this.top_stories = top_stories;
// }
//
// }
| import com.liuguangqiang.idaily.entity.Daily;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Path; | package com.liuguangqiang.idaily.api.service;
/**
* Created by Eric on 16/3/21.
*/
public interface DailyService {
@GET("news/latest") | // Path: app/src/main/java/com/liuguangqiang/idaily/entity/Daily.java
// public class Daily extends BaseEntity {
//
// private int id;
//
// private int date;
//
// private List<Story> stories;
//
// private List<Story> top_stories;
//
// public int getDate() {
// return date;
// }
//
// public void setDate(int date) {
// this.date = date;
// }
//
// public List<Story> getStories() {
// return stories;
// }
//
// public void setStories(List<Story> stories) {
// this.stories = stories;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public List<Story> getTop_stories() {
// return top_stories;
// }
//
// public void setTop_stories(List<Story> top_stories) {
// this.top_stories = top_stories;
// }
//
// }
// Path: app/src/main/java/com/liuguangqiang/idaily/api/service/DailyService.java
import com.liuguangqiang.idaily.entity.Daily;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Path;
package com.liuguangqiang.idaily.api.service;
/**
* Created by Eric on 16/3/21.
*/
public interface DailyService {
@GET("news/latest") | Observable<Daily> getLatest(); |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Message.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/AuthorView.java
// @XmlRootElement
// public interface AuthorView {
//
// @XmlAttribute
// String getNickName();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
| import com.googlecode.cqengine.attribute.Attribute;
import com.googlecode.cqengine.attribute.SimpleAttribute;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoLocalDateTime;
import javax.xml.bind.annotation.XmlElement;
import pl.setblack.airomem.chatsample.view.AuthorView;
import pl.setblack.airomem.chatsample.view.MessageView; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarekr
*/
public class Message implements MessageView, Serializable {
private static final long serialVersionUID = 1;
public static final SimpleAttribute<Message, ChronoLocalDateTime> MESSAGE_TIME
= new SimpleAttribute<Message, ChronoLocalDateTime>() {
@Override
public ChronoLocalDateTime getValue(Message msg) {
return msg.getTime();
}
};
private final Author author;
private final String content;
private final LocalDateTime time;
public Message(Author author, String content, LocalDateTime time) {
this.author = author;
this.content = content;
this.time = time;
}
@Override
public String getContent() {
return content;
}
@Override
public LocalDateTime getTime() {
return time;
}
@Override
@XmlElement | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/AuthorView.java
// @XmlRootElement
// public interface AuthorView {
//
// @XmlAttribute
// String getNickName();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Message.java
import com.googlecode.cqengine.attribute.Attribute;
import com.googlecode.cqengine.attribute.SimpleAttribute;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoLocalDateTime;
import javax.xml.bind.annotation.XmlElement;
import pl.setblack.airomem.chatsample.view.AuthorView;
import pl.setblack.airomem.chatsample.view.MessageView;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarekr
*/
public class Message implements MessageView, Serializable {
private static final long serialVersionUID = 1;
public static final SimpleAttribute<Message, ChronoLocalDateTime> MESSAGE_TIME
= new SimpleAttribute<Message, ChronoLocalDateTime>() {
@Override
public ChronoLocalDateTime getValue(Message msg) {
return msg.getTime();
}
};
private final Author author;
private final String content;
private final LocalDateTime time;
public Message(Author author, String content, LocalDateTime time) {
this.author = author;
this.content = content;
this.time = time;
}
@Override
public String getContent() {
return content;
}
@Override
public LocalDateTime getTime() {
return time;
}
@Override
@XmlElement | public AuthorView getAuthorView() { |
airomem/airomem | airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/PrevaylerRegisterTest.java | // Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleObject.java
// public class SampleObject implements Serializable {
//
// private static final long serialVersionUID = 1l;
//
// private String field1;
//
// private String field2;
//
// public int value;
//
// public SampleObject() {
// }
//
// public String getField1() {
// return field1;
// }
//
// public void setField1(String field1) {
// this.field1 = field1;
// }
//
// public String getField2() {
// return field2;
// }
//
// public void setField2(String field2) {
// this.field2 = field2;
// }
//
// }
| import java.io.File;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.SampleObject;
import pl.setblack.badass.Politician;
| /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
public class PrevaylerRegisterTest {
public PrevaylerRegisterTest() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
PrevaylerRegister.getInstance().clear();
Politician.beatAroundTheBush(() -> {
FileUtils.deleteDirectory(new File(PersistenceFactory.STORAGE_FOLDER));
});
}
@Test
public void shouldReturnSameInstance() {
final PrevaylerRegister inst1 = PrevaylerRegister.getInstance();
final PrevaylerRegister inst2 = PrevaylerRegister.getInstance();
assertTrue(inst1 == inst2);
}
@Test
public void shouldReturnPrevaylerOfGivenClass() {
| // Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleObject.java
// public class SampleObject implements Serializable {
//
// private static final long serialVersionUID = 1l;
//
// private String field1;
//
// private String field2;
//
// public int value;
//
// public SampleObject() {
// }
//
// public String getField1() {
// return field1;
// }
//
// public void setField1(String field1) {
// this.field1 = field1;
// }
//
// public String getField2() {
// return field2;
// }
//
// public void setField2(String field2) {
// this.field2 = field2;
// }
//
// }
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/PrevaylerRegisterTest.java
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.SampleObject;
import pl.setblack.badass.Politician;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
public class PrevaylerRegisterTest {
public PrevaylerRegisterTest() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
PrevaylerRegister.getInstance().clear();
Politician.beatAroundTheBush(() -> {
FileUtils.deleteDirectory(new File(PersistenceFactory.STORAGE_FOLDER));
});
}
@Test
public void shouldReturnSameInstance() {
final PrevaylerRegister inst1 = PrevaylerRegister.getInstance();
final PrevaylerRegister inst2 = PrevaylerRegister.getInstance();
assertTrue(inst1 == inst2);
}
@Test
public void shouldReturnPrevaylerOfGivenClass() {
| final SimpleController<SampleObject> obj = PrevaylerRegister.getInstance().getController(SampleObject.class, "test");
|
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/WriteCheckerTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import static org.junit.Assert.*; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class WriteCheckerTest {
private PrevalanceContext ctx1;
private PrevalanceContext ctx2;
@Before
public void setUp() {
ctx1 = Mockito.mock(PrevalanceContext.class);
ctx2 = Mockito.mock(PrevalanceContext.class); | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/WriteCheckerTest.java
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import static org.junit.Assert.*;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class WriteCheckerTest {
private PrevalanceContext ctx1;
private PrevalanceContext ctx2;
@Before
public void setUp() {
ctx1 = Mockito.mock(PrevalanceContext.class);
ctx2 = Mockito.mock(PrevalanceContext.class); | if (WriteChecker.hasPrevalanceContext()) { |
airomem/airomem | airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/ClassContextTest.java | // Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
| import java.io.File;
import java.lang.reflect.Method;
import org.apache.commons.io.FileUtils;
import org.jglue.cdiunit.CdiRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;
| /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class ClassContextTest {
public ClassContextTest() {
}
@Before
public void setUp() {
PrevaylerRegister.getInstance().clear();
Politician.beatAroundTheBush(() -> {
FileUtils.deleteDirectory(new File(PersistenceFactory.STORAGE_FOLDER));
});
}
@After
public void tearDown() {
PrevaylerRegister.getInstance().clear();
Politician.beatAroundTheBush(() -> {
FileUtils.deleteDirectory(new File(PersistenceFactory.STORAGE_FOLDER));
});
}
@Test(expected = IllegalStateException.class)
public void shouldNotInstantiateNoCDIBean() throws NoSuchMethodException {
//WHEN
final ClassContext ctx = new ClassContext(Object.class);
}
@Test(expected = RuntimeException.class)
public void shouldFailOnNoBeanClass() throws NoSuchMethodException {
//GIVEN
| // Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/ClassContextTest.java
import java.io.File;
import java.lang.reflect.Method;
import org.apache.commons.io.FileUtils;
import org.jglue.cdiunit.CdiRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class ClassContextTest {
public ClassContextTest() {
}
@Before
public void setUp() {
PrevaylerRegister.getInstance().clear();
Politician.beatAroundTheBush(() -> {
FileUtils.deleteDirectory(new File(PersistenceFactory.STORAGE_FOLDER));
});
}
@After
public void tearDown() {
PrevaylerRegister.getInstance().clear();
Politician.beatAroundTheBush(() -> {
FileUtils.deleteDirectory(new File(PersistenceFactory.STORAGE_FOLDER));
});
}
@Test(expected = IllegalStateException.class)
public void shouldNotInstantiateNoCDIBean() throws NoSuchMethodException {
//WHEN
final ClassContext ctx = new ClassContext(Object.class);
}
@Test(expected = RuntimeException.class)
public void shouldFailOnNoBeanClass() throws NoSuchMethodException {
//GIVEN
| SampleController ctrl = new SampleController() {
|
airomem/airomem | airomem-direct/src/test/java/pl/setblack/airomem/direct/ContainerTest.java | // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/PrevaylerRegister.java
// public final class PrevaylerRegister {
//
// private static final PrevaylerRegister INSTANCE = new PrevaylerRegister();
//
// private final ConcurrentHashMap<String, SimpleController> prevaylers = new ConcurrentHashMap<>();
//
// public static final PrevaylerRegister getInstance() {
// return PrevaylerRegister.INSTANCE;
// }
//
// public void clear() {
// for (final SimpleController ctrl : this.prevaylers.values()) {
// ctrl.close();
// }
// this.prevaylers.clear();
// }
//
// public <T extends Serializable> SimpleController<T> getController(final Class<T> type, final String name) {
// final String fullName = calcName(type, name);
// final SimpleController<T> existing = this.prevaylers.get(fullName);
// if (existing != null) {
// return existing;
// } else {
// final SimpleController<T> newPrevayler = createController(type, name);
// this.prevaylers.putIfAbsent(fullName, newPrevayler);
// return this.prevaylers.get(fullName);
// }
//
// }
//
// private <T extends Serializable> SimpleController<T> createController(Class<T> type, String name) {
// SimpleController<T> controller = SimpleController.loadOptional(name, () -> createInitialState(type));
// return controller;
// }
//
// private <T extends Serializable> T createInitialState(Class<T> type) {
// return Politician.beatAroundTheBush(() -> {
// final Constructor<T> constr = type.getDeclaredConstructor();
// return constr.newInstance();
// });
// }
//
// private static <T> String calcName(final Class<T> clazz, final String name) {
// return clazz.getCanonicalName() + name;
// }
//
// public void shut() {
// for (final SimpleController ctrl : this.prevaylers.values()) {
// ctrl.shut();
// }
// this.prevaylers.clear();
// }
// }
| import java.io.File;
import java.lang.reflect.Method;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import org.jglue.cdiunit.AdditionalClasses;
import org.jglue.cdiunit.CdiRunner;
import org.junit.After;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.direct.impl.PrevaylerRegister;
import pl.setblack.badass.Politician; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct;
/**
*
*/
@RunWith(CdiRunner.class)
@AdditionalClasses(PersistenceInterceptor.class)
public class ContainerTest {
@Inject
SampleController controller;
@Inject
SampleController controller2;
@Before @After
public void clean() { | // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/PrevaylerRegister.java
// public final class PrevaylerRegister {
//
// private static final PrevaylerRegister INSTANCE = new PrevaylerRegister();
//
// private final ConcurrentHashMap<String, SimpleController> prevaylers = new ConcurrentHashMap<>();
//
// public static final PrevaylerRegister getInstance() {
// return PrevaylerRegister.INSTANCE;
// }
//
// public void clear() {
// for (final SimpleController ctrl : this.prevaylers.values()) {
// ctrl.close();
// }
// this.prevaylers.clear();
// }
//
// public <T extends Serializable> SimpleController<T> getController(final Class<T> type, final String name) {
// final String fullName = calcName(type, name);
// final SimpleController<T> existing = this.prevaylers.get(fullName);
// if (existing != null) {
// return existing;
// } else {
// final SimpleController<T> newPrevayler = createController(type, name);
// this.prevaylers.putIfAbsent(fullName, newPrevayler);
// return this.prevaylers.get(fullName);
// }
//
// }
//
// private <T extends Serializable> SimpleController<T> createController(Class<T> type, String name) {
// SimpleController<T> controller = SimpleController.loadOptional(name, () -> createInitialState(type));
// return controller;
// }
//
// private <T extends Serializable> T createInitialState(Class<T> type) {
// return Politician.beatAroundTheBush(() -> {
// final Constructor<T> constr = type.getDeclaredConstructor();
// return constr.newInstance();
// });
// }
//
// private static <T> String calcName(final Class<T> clazz, final String name) {
// return clazz.getCanonicalName() + name;
// }
//
// public void shut() {
// for (final SimpleController ctrl : this.prevaylers.values()) {
// ctrl.shut();
// }
// this.prevaylers.clear();
// }
// }
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/ContainerTest.java
import java.io.File;
import java.lang.reflect.Method;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import org.jglue.cdiunit.AdditionalClasses;
import org.jglue.cdiunit.CdiRunner;
import org.junit.After;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.direct.impl.PrevaylerRegister;
import pl.setblack.badass.Politician;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct;
/**
*
*/
@RunWith(CdiRunner.class)
@AdditionalClasses(PersistenceInterceptor.class)
public class ContainerTest {
@Inject
SampleController controller;
@Inject
SampleController controller2;
@Before @After
public void clean() { | PrevaylerRegister.getInstance().clear(); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/PersistentTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/Persistent.java
// public class Persistent<T extends Serializable> implements AutoCloseable {
//
// private final PersistenceController<DataRoot<T>> controller;
//
// private Persistent(PersistenceController<DataRoot<T>> controller) {
// this.controller = controller;
// }
//
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static <T extends Serializable> Persistent<T> load(Path path) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .withFolder(path)
// .build());
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor, boolean useRoyalFoodTester) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(constructor.get()))
// .withRoyalFoodTester(useRoyalFoodTester)
// .withFolder(path)
// .build());
//
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor) {
// return loadOptional(path, constructor, true);
// }
//
//
// public static <T extends Serializable> Persistent<T> create(Path path, T initial) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(initial))
// .forceOverwrite(true)
// .withFolder(path)
// .build());
// }
//
// public <RESULT> RESULT query(Query<T, RESULT> query) {
// return controller.query((dataRoot) -> query.evaluate(dataRoot.getDataObject()));
// }
//
// public T readOnly() {
// return query(t -> t);
// }
//
// @Override
// public void close() {
// this.controller.close();
// }
//
// public void shut() {
// this.controller.shut();
// }
//
// public boolean isOpen() {
// return controller.isOpen();
// }
//
// public <R> R executeAndQuery(ContextCommand<T, R> cmd) {
// return controller.executeAndQuery((ContextCommand<DataRoot<T>, R>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public <R> R executeAndQuery(Command<T, R> cmd) {
// return controller.executeAndQuery((Command<DataRoot<T>, R>) (x -> cmd.execute(x.getDataObject())));
// }
//
// public void execute(VoidContextCommand<T> cmd) {
// controller.execute((VoidContextCommand<DataRoot<T>>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public void execute(VoidCommand<T> cmd) {
// controller.execute((VoidCommand<DataRoot<T>>) (x -> cmd.execute(x.getDataObject())));
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PersistentTest {
private final File localFolder = new File("prevayler");
@Before
public void setUp() { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/Persistent.java
// public class Persistent<T extends Serializable> implements AutoCloseable {
//
// private final PersistenceController<DataRoot<T>> controller;
//
// private Persistent(PersistenceController<DataRoot<T>> controller) {
// this.controller = controller;
// }
//
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static <T extends Serializable> Persistent<T> load(Path path) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .withFolder(path)
// .build());
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor, boolean useRoyalFoodTester) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(constructor.get()))
// .withRoyalFoodTester(useRoyalFoodTester)
// .withFolder(path)
// .build());
//
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor) {
// return loadOptional(path, constructor, true);
// }
//
//
// public static <T extends Serializable> Persistent<T> create(Path path, T initial) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(initial))
// .forceOverwrite(true)
// .withFolder(path)
// .build());
// }
//
// public <RESULT> RESULT query(Query<T, RESULT> query) {
// return controller.query((dataRoot) -> query.evaluate(dataRoot.getDataObject()));
// }
//
// public T readOnly() {
// return query(t -> t);
// }
//
// @Override
// public void close() {
// this.controller.close();
// }
//
// public void shut() {
// this.controller.shut();
// }
//
// public boolean isOpen() {
// return controller.isOpen();
// }
//
// public <R> R executeAndQuery(ContextCommand<T, R> cmd) {
// return controller.executeAndQuery((ContextCommand<DataRoot<T>, R>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public <R> R executeAndQuery(Command<T, R> cmd) {
// return controller.executeAndQuery((Command<DataRoot<T>, R>) (x -> cmd.execute(x.getDataObject())));
// }
//
// public void execute(VoidContextCommand<T> cmd) {
// controller.execute((VoidContextCommand<DataRoot<T>>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public void execute(VoidCommand<T> cmd) {
// controller.execute((VoidCommand<DataRoot<T>>) (x -> cmd.execute(x.getDataObject())));
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/PersistentTest.java
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PersistentTest {
private final File localFolder = new File("prevayler");
@Before
public void setUp() { | PersistenceDiskHelper.delete(localFolder.toPath()); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/PersistentTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/Persistent.java
// public class Persistent<T extends Serializable> implements AutoCloseable {
//
// private final PersistenceController<DataRoot<T>> controller;
//
// private Persistent(PersistenceController<DataRoot<T>> controller) {
// this.controller = controller;
// }
//
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static <T extends Serializable> Persistent<T> load(Path path) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .withFolder(path)
// .build());
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor, boolean useRoyalFoodTester) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(constructor.get()))
// .withRoyalFoodTester(useRoyalFoodTester)
// .withFolder(path)
// .build());
//
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor) {
// return loadOptional(path, constructor, true);
// }
//
//
// public static <T extends Serializable> Persistent<T> create(Path path, T initial) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(initial))
// .forceOverwrite(true)
// .withFolder(path)
// .build());
// }
//
// public <RESULT> RESULT query(Query<T, RESULT> query) {
// return controller.query((dataRoot) -> query.evaluate(dataRoot.getDataObject()));
// }
//
// public T readOnly() {
// return query(t -> t);
// }
//
// @Override
// public void close() {
// this.controller.close();
// }
//
// public void shut() {
// this.controller.shut();
// }
//
// public boolean isOpen() {
// return controller.isOpen();
// }
//
// public <R> R executeAndQuery(ContextCommand<T, R> cmd) {
// return controller.executeAndQuery((ContextCommand<DataRoot<T>, R>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public <R> R executeAndQuery(Command<T, R> cmd) {
// return controller.executeAndQuery((Command<DataRoot<T>, R>) (x -> cmd.execute(x.getDataObject())));
// }
//
// public void execute(VoidContextCommand<T> cmd) {
// controller.execute((VoidContextCommand<DataRoot<T>>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public void execute(VoidCommand<T> cmd) {
// controller.execute((VoidCommand<DataRoot<T>>) (x -> cmd.execute(x.getDataObject())));
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PersistentTest {
private final File localFolder = new File("prevayler");
@Before
public void setUp() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@After
public void tearDown() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@Test
public void testSimpleControllerCreation() {
//GIVEN | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/Persistent.java
// public class Persistent<T extends Serializable> implements AutoCloseable {
//
// private final PersistenceController<DataRoot<T>> controller;
//
// private Persistent(PersistenceController<DataRoot<T>> controller) {
// this.controller = controller;
// }
//
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static <T extends Serializable> Persistent<T> load(Path path) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .withFolder(path)
// .build());
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor, boolean useRoyalFoodTester) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(constructor.get()))
// .withRoyalFoodTester(useRoyalFoodTester)
// .withFolder(path)
// .build());
//
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor) {
// return loadOptional(path, constructor, true);
// }
//
//
// public static <T extends Serializable> Persistent<T> create(Path path, T initial) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(initial))
// .forceOverwrite(true)
// .withFolder(path)
// .build());
// }
//
// public <RESULT> RESULT query(Query<T, RESULT> query) {
// return controller.query((dataRoot) -> query.evaluate(dataRoot.getDataObject()));
// }
//
// public T readOnly() {
// return query(t -> t);
// }
//
// @Override
// public void close() {
// this.controller.close();
// }
//
// public void shut() {
// this.controller.shut();
// }
//
// public boolean isOpen() {
// return controller.isOpen();
// }
//
// public <R> R executeAndQuery(ContextCommand<T, R> cmd) {
// return controller.executeAndQuery((ContextCommand<DataRoot<T>, R>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public <R> R executeAndQuery(Command<T, R> cmd) {
// return controller.executeAndQuery((Command<DataRoot<T>, R>) (x -> cmd.execute(x.getDataObject())));
// }
//
// public void execute(VoidContextCommand<T> cmd) {
// controller.execute((VoidContextCommand<DataRoot<T>>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public void execute(VoidCommand<T> cmd) {
// controller.execute((VoidCommand<DataRoot<T>>) (x -> cmd.execute(x.getDataObject())));
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/PersistentTest.java
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PersistentTest {
private final File localFolder = new File("prevayler");
@Before
public void setUp() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@After
public void tearDown() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@Test
public void testSimpleControllerCreation() {
//GIVEN | final Persistent<HashMap<String, String>> persistent = Persistent.create(localFolder.toPath(), StorableObject.createTestHashMap()); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/PersistentTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/Persistent.java
// public class Persistent<T extends Serializable> implements AutoCloseable {
//
// private final PersistenceController<DataRoot<T>> controller;
//
// private Persistent(PersistenceController<DataRoot<T>> controller) {
// this.controller = controller;
// }
//
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static <T extends Serializable> Persistent<T> load(Path path) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .withFolder(path)
// .build());
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor, boolean useRoyalFoodTester) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(constructor.get()))
// .withRoyalFoodTester(useRoyalFoodTester)
// .withFolder(path)
// .build());
//
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor) {
// return loadOptional(path, constructor, true);
// }
//
//
// public static <T extends Serializable> Persistent<T> create(Path path, T initial) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(initial))
// .forceOverwrite(true)
// .withFolder(path)
// .build());
// }
//
// public <RESULT> RESULT query(Query<T, RESULT> query) {
// return controller.query((dataRoot) -> query.evaluate(dataRoot.getDataObject()));
// }
//
// public T readOnly() {
// return query(t -> t);
// }
//
// @Override
// public void close() {
// this.controller.close();
// }
//
// public void shut() {
// this.controller.shut();
// }
//
// public boolean isOpen() {
// return controller.isOpen();
// }
//
// public <R> R executeAndQuery(ContextCommand<T, R> cmd) {
// return controller.executeAndQuery((ContextCommand<DataRoot<T>, R>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public <R> R executeAndQuery(Command<T, R> cmd) {
// return controller.executeAndQuery((Command<DataRoot<T>, R>) (x -> cmd.execute(x.getDataObject())));
// }
//
// public void execute(VoidContextCommand<T> cmd) {
// controller.execute((VoidContextCommand<DataRoot<T>>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public void execute(VoidCommand<T> cmd) {
// controller.execute((VoidCommand<DataRoot<T>>) (x -> cmd.execute(x.getDataObject())));
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PersistentTest {
private final File localFolder = new File("prevayler");
@Before
public void setUp() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@After
public void tearDown() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@Test
public void testSimpleControllerCreation() {
//GIVEN | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/Persistent.java
// public class Persistent<T extends Serializable> implements AutoCloseable {
//
// private final PersistenceController<DataRoot<T>> controller;
//
// private Persistent(PersistenceController<DataRoot<T>> controller) {
// this.controller = controller;
// }
//
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static <T extends Serializable> Persistent<T> load(Path path) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .withFolder(path)
// .build());
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor, boolean useRoyalFoodTester) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(constructor.get()))
// .withRoyalFoodTester(useRoyalFoodTester)
// .withFolder(path)
// .build());
//
// }
//
// public static <T extends Serializable> Persistent<T> loadOptional(Path path, Supplier<T> constructor) {
// return loadOptional(path, constructor, true);
// }
//
//
// public static <T extends Serializable> Persistent<T> create(Path path, T initial) {
// return new Persistent<T>(PrevaylerBuilder.<DataRoot<T>>newBuilder()
// .useSupplier(() -> new DataRoot<>(initial))
// .forceOverwrite(true)
// .withFolder(path)
// .build());
// }
//
// public <RESULT> RESULT query(Query<T, RESULT> query) {
// return controller.query((dataRoot) -> query.evaluate(dataRoot.getDataObject()));
// }
//
// public T readOnly() {
// return query(t -> t);
// }
//
// @Override
// public void close() {
// this.controller.close();
// }
//
// public void shut() {
// this.controller.shut();
// }
//
// public boolean isOpen() {
// return controller.isOpen();
// }
//
// public <R> R executeAndQuery(ContextCommand<T, R> cmd) {
// return controller.executeAndQuery((ContextCommand<DataRoot<T>, R>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public <R> R executeAndQuery(Command<T, R> cmd) {
// return controller.executeAndQuery((Command<DataRoot<T>, R>) (x -> cmd.execute(x.getDataObject())));
// }
//
// public void execute(VoidContextCommand<T> cmd) {
// controller.execute((VoidContextCommand<DataRoot<T>>) ((x, ctx) -> cmd.execute(x.getDataObject(), ctx)));
// }
//
// public void execute(VoidCommand<T> cmd) {
// controller.execute((VoidCommand<DataRoot<T>>) (x -> cmd.execute(x.getDataObject())));
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/PersistentTest.java
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PersistentTest {
private final File localFolder = new File("prevayler");
@Before
public void setUp() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@After
public void tearDown() {
PersistenceDiskHelper.delete(localFolder.toPath());
}
@Test
public void testSimpleControllerCreation() {
//GIVEN | final Persistent<HashMap<String, String>> persistent = Persistent.create(localFolder.toPath(), StorableObject.createTestHashMap()); |
airomem/airomem | airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/TransactionAnalyzerTest.java | // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
| import java.lang.reflect.Method;
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;
| /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class TransactionAnalyzerTest {
| // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/TransactionAnalyzerTest.java
import java.lang.reflect.Method;
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class TransactionAnalyzerTest {
| private final SampleController controler = new SampleController();
|
airomem/airomem | airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/TransactionAnalyzerTest.java | // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
| import java.lang.reflect.Method;
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;
| /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class TransactionAnalyzerTest {
private final SampleController controler = new SampleController();
@Inject
private TransactionAnalyzer analyzer;
public TransactionAnalyzerTest() {
}
private Method getMethod(final Object object, final String name) {
return Politician.beatAroundTheBush(() -> object.getClass().getMethod(name));
}
@Before
public void setUp() {
}
@Test
public void shouldSayWriteForWriteMethod() {
final Method method = getMethod(controler, "writeMethod");
//THEN
| // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/TransactionAnalyzerTest.java
import java.lang.reflect.Method;
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class TransactionAnalyzerTest {
private final SampleController controler = new SampleController();
@Inject
private TransactionAnalyzer analyzer;
public TransactionAnalyzerTest() {
}
private Method getMethod(final Object object, final String name) {
return Politician.beatAroundTheBush(() -> object.getClass().getMethod(name));
}
@Before
public void setUp() {
}
@Test
public void shouldSayWriteForWriteMethod() {
final Method method = getMethod(controler, "writeMethod");
//THEN
| assertEquals(OperationType.WRITE, analyzer.sayTypeOf(method));
|
airomem/airomem | airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/rest/BankResource.java | // Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Account.java
// public final class Account implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
//
//
// public final String id;
//
// public final BigDecimal value;
//
// protected Account() {
// id = "";
// value= BigDecimal.ONE;
// }
//
// Account(final String id, final BigDecimal value) {
// this.id = id;
// this.value = value;
// }
//
// Account change(final BigDecimal change) {
// return new Account(this.id, value.add(change));
// }
//
// }
//
// Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Bank.java
// public final class Bank implements Serializable {
//
// private static final long serialVersionUID = 1l;
// private final Random random = new Random(42);
//
// private transient RandomBasedGenerator uuidGenerator;
//
// private final Map<String, Account> accounts = new ConcurrentHashMap<>();
//
// /**
// * This conctructor is needed by airomem direct.
// */
// public Bank() {
//
// }
//
// private synchronized String generateId() {
// if (uuidGenerator == null) {
// uuidGenerator = Generators.randomBasedGenerator(random);
// }
// return uuidGenerator.generate().toString();
// }
//
// public BigDecimal getTotalAmount() {
// return BigDecimal.ZERO;
// }
//
// public Account registerNewAccount(BigDecimal value) {
// final Account acc = new Account(generateId(), value);
// this.accounts.put(acc.id, acc);
// return acc;
// }
//
// public Account getAccount(String id) {
// return this.accounts.get(id);
// }
//
// public Account change(String id, BigDecimal value) {
// Account changed = this.accounts.get(id).change(value);
// this.accounts.put(id, changed);
// return changed;
// }
//
// public Iterable<Account> getAllAccounts() {
// return Collections.unmodifiableCollection(this.accounts.values());
// }
// }
| import java.math.BigDecimal;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import pl.setblack.airomem.direct.Persistent;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.airomem.direct.banksample.domain.Account;
import pl.setblack.airomem.direct.banksample.domain.Bank; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.direct.banksample.rest;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("bank")
@Persistent
public class BankResource {
@PersistentObject | // Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Account.java
// public final class Account implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
//
//
// public final String id;
//
// public final BigDecimal value;
//
// protected Account() {
// id = "";
// value= BigDecimal.ONE;
// }
//
// Account(final String id, final BigDecimal value) {
// this.id = id;
// this.value = value;
// }
//
// Account change(final BigDecimal change) {
// return new Account(this.id, value.add(change));
// }
//
// }
//
// Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Bank.java
// public final class Bank implements Serializable {
//
// private static final long serialVersionUID = 1l;
// private final Random random = new Random(42);
//
// private transient RandomBasedGenerator uuidGenerator;
//
// private final Map<String, Account> accounts = new ConcurrentHashMap<>();
//
// /**
// * This conctructor is needed by airomem direct.
// */
// public Bank() {
//
// }
//
// private synchronized String generateId() {
// if (uuidGenerator == null) {
// uuidGenerator = Generators.randomBasedGenerator(random);
// }
// return uuidGenerator.generate().toString();
// }
//
// public BigDecimal getTotalAmount() {
// return BigDecimal.ZERO;
// }
//
// public Account registerNewAccount(BigDecimal value) {
// final Account acc = new Account(generateId(), value);
// this.accounts.put(acc.id, acc);
// return acc;
// }
//
// public Account getAccount(String id) {
// return this.accounts.get(id);
// }
//
// public Account change(String id, BigDecimal value) {
// Account changed = this.accounts.get(id).change(value);
// this.accounts.put(id, changed);
// return changed;
// }
//
// public Iterable<Account> getAllAccounts() {
// return Collections.unmodifiableCollection(this.accounts.values());
// }
// }
// Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/rest/BankResource.java
import java.math.BigDecimal;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import pl.setblack.airomem.direct.Persistent;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.airomem.direct.banksample.domain.Account;
import pl.setblack.airomem.direct.banksample.domain.Bank;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.direct.banksample.rest;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("bank")
@Persistent
public class BankResource {
@PersistentObject | private Bank bank; |
airomem/airomem | airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/rest/BankResource.java | // Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Account.java
// public final class Account implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
//
//
// public final String id;
//
// public final BigDecimal value;
//
// protected Account() {
// id = "";
// value= BigDecimal.ONE;
// }
//
// Account(final String id, final BigDecimal value) {
// this.id = id;
// this.value = value;
// }
//
// Account change(final BigDecimal change) {
// return new Account(this.id, value.add(change));
// }
//
// }
//
// Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Bank.java
// public final class Bank implements Serializable {
//
// private static final long serialVersionUID = 1l;
// private final Random random = new Random(42);
//
// private transient RandomBasedGenerator uuidGenerator;
//
// private final Map<String, Account> accounts = new ConcurrentHashMap<>();
//
// /**
// * This conctructor is needed by airomem direct.
// */
// public Bank() {
//
// }
//
// private synchronized String generateId() {
// if (uuidGenerator == null) {
// uuidGenerator = Generators.randomBasedGenerator(random);
// }
// return uuidGenerator.generate().toString();
// }
//
// public BigDecimal getTotalAmount() {
// return BigDecimal.ZERO;
// }
//
// public Account registerNewAccount(BigDecimal value) {
// final Account acc = new Account(generateId(), value);
// this.accounts.put(acc.id, acc);
// return acc;
// }
//
// public Account getAccount(String id) {
// return this.accounts.get(id);
// }
//
// public Account change(String id, BigDecimal value) {
// Account changed = this.accounts.get(id).change(value);
// this.accounts.put(id, changed);
// return changed;
// }
//
// public Iterable<Account> getAllAccounts() {
// return Collections.unmodifiableCollection(this.accounts.values());
// }
// }
| import java.math.BigDecimal;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import pl.setblack.airomem.direct.Persistent;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.airomem.direct.banksample.domain.Account;
import pl.setblack.airomem.direct.banksample.domain.Bank; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.direct.banksample.rest;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("bank")
@Persistent
public class BankResource {
@PersistentObject
private Bank bank;
public BankResource() {
}
@GET
@Path("/account/{id}")
@Produces(MediaType.APPLICATION_JSON) | // Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Account.java
// public final class Account implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
//
//
// public final String id;
//
// public final BigDecimal value;
//
// protected Account() {
// id = "";
// value= BigDecimal.ONE;
// }
//
// Account(final String id, final BigDecimal value) {
// this.id = id;
// this.value = value;
// }
//
// Account change(final BigDecimal change) {
// return new Account(this.id, value.add(change));
// }
//
// }
//
// Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/domain/Bank.java
// public final class Bank implements Serializable {
//
// private static final long serialVersionUID = 1l;
// private final Random random = new Random(42);
//
// private transient RandomBasedGenerator uuidGenerator;
//
// private final Map<String, Account> accounts = new ConcurrentHashMap<>();
//
// /**
// * This conctructor is needed by airomem direct.
// */
// public Bank() {
//
// }
//
// private synchronized String generateId() {
// if (uuidGenerator == null) {
// uuidGenerator = Generators.randomBasedGenerator(random);
// }
// return uuidGenerator.generate().toString();
// }
//
// public BigDecimal getTotalAmount() {
// return BigDecimal.ZERO;
// }
//
// public Account registerNewAccount(BigDecimal value) {
// final Account acc = new Account(generateId(), value);
// this.accounts.put(acc.id, acc);
// return acc;
// }
//
// public Account getAccount(String id) {
// return this.accounts.get(id);
// }
//
// public Account change(String id, BigDecimal value) {
// Account changed = this.accounts.get(id).change(value);
// this.accounts.put(id, changed);
// return changed;
// }
//
// public Iterable<Account> getAllAccounts() {
// return Collections.unmodifiableCollection(this.accounts.values());
// }
// }
// Path: airomem-direct-banksample/src/main/java/pl/setblack/airomem/direct/banksample/rest/BankResource.java
import java.math.BigDecimal;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import pl.setblack.airomem.direct.Persistent;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.airomem.direct.banksample.domain.Account;
import pl.setblack.airomem.direct.banksample.domain.Bank;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.direct.banksample.rest;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("bank")
@Persistent
public class BankResource {
@PersistentObject
private Bank bank;
public BankResource() {
}
@GET
@Path("/account/{id}")
@Produces(MediaType.APPLICATION_JSON) | public Account getAccount(@PathParam("id") final String id) { |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/PrevaylerBuilderTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/RestoreException.java
// public class RestoreException extends RuntimeException {
//
// public RestoreException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidCommand.java
// public interface VoidCommand<T> extends Command<T, Void> {
//
// @Override
// default Void execute(T system) {
// this.executeVoid(system);
// return null;
// }
//
// void executeVoid(T system);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.prevayler.foundation.serialization.JavaSerializer;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.RestoreException;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidCommand;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.*; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PrevaylerBuilderTest {
private static final AtomicReference<Boolean> failureMarker = new AtomicReference<>(Boolean.FALSE);
final Path testFolder = new File("prevayler/test").toPath();
private static boolean isFailureNeeded() {
return failureMarker.get();
}
@Before
public void setUp() {
deletePrevaylerFolders();
failureMarker.set(Boolean.FALSE);
}
private void deletePrevaylerFolders() { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/RestoreException.java
// public class RestoreException extends RuntimeException {
//
// public RestoreException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidCommand.java
// public interface VoidCommand<T> extends Command<T, Void> {
//
// @Override
// default Void execute(T system) {
// this.executeVoid(system);
// return null;
// }
//
// void executeVoid(T system);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/PrevaylerBuilderTest.java
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.prevayler.foundation.serialization.JavaSerializer;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.RestoreException;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidCommand;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.*;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.builders;
/**
* @author jarek ratajski
*/
public class PrevaylerBuilderTest {
private static final AtomicReference<Boolean> failureMarker = new AtomicReference<>(Boolean.FALSE);
final Path testFolder = new File("prevayler/test").toPath();
private static boolean isFailureNeeded() {
return failureMarker.get();
}
@Before
public void setUp() {
deletePrevaylerFolders();
failureMarker.set(Boolean.FALSE);
}
private void deletePrevaylerFolders() { | PersistenceDiskHelper.delete(this.testFolder); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/PrevaylerBuilderTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/RestoreException.java
// public class RestoreException extends RuntimeException {
//
// public RestoreException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidCommand.java
// public interface VoidCommand<T> extends Command<T, Void> {
//
// @Override
// default Void execute(T system) {
// this.executeVoid(system);
// return null;
// }
//
// void executeVoid(T system);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.prevayler.foundation.serialization.JavaSerializer;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.RestoreException;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidCommand;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.*; | @Test
public void shouldUseFastSerializerForJournaling() {
//GIVEN
final PrevaylerBuilder<StorableObject> builder = PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.withJournalFastSerialization(true);
StrangeTransaction.counter = 0;
//WHEN
try (
final PersistenceController<StorableObject> ctrl = builder.build();) {
ctrl.execute(new StrangeTransaction());
}
assertTrue(StrangeTransaction.counter == 0);
}
@Test
public void shouldUseCustomSerializerForJournaling() {
//GIVEN
final PrevaylerBuilder<StorableObject> builder = PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.useCustomJavaSerializer(new JavaSerializer());
StrangeTransaction.counter = 0;
//WHEN
try (
final PersistenceController<StorableObject> ctrl = builder.build();) {
ctrl.execute(new StrangeTransaction());
}
assertTrue(StrangeTransaction.counter == 0);
}
| // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/RestoreException.java
// public class RestoreException extends RuntimeException {
//
// public RestoreException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidCommand.java
// public interface VoidCommand<T> extends Command<T, Void> {
//
// @Override
// default Void execute(T system) {
// this.executeVoid(system);
// return null;
// }
//
// void executeVoid(T system);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/PrevaylerBuilderTest.java
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.prevayler.foundation.serialization.JavaSerializer;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.RestoreException;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidCommand;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.*;
@Test
public void shouldUseFastSerializerForJournaling() {
//GIVEN
final PrevaylerBuilder<StorableObject> builder = PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.withJournalFastSerialization(true);
StrangeTransaction.counter = 0;
//WHEN
try (
final PersistenceController<StorableObject> ctrl = builder.build();) {
ctrl.execute(new StrangeTransaction());
}
assertTrue(StrangeTransaction.counter == 0);
}
@Test
public void shouldUseCustomSerializerForJournaling() {
//GIVEN
final PrevaylerBuilder<StorableObject> builder = PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.useCustomJavaSerializer(new JavaSerializer());
StrangeTransaction.counter = 0;
//WHEN
try (
final PersistenceController<StorableObject> ctrl = builder.build();) {
ctrl.execute(new StrangeTransaction());
}
assertTrue(StrangeTransaction.counter == 0);
}
| @Test(expected = RestoreException.class) |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/PrevaylerBuilderTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/RestoreException.java
// public class RestoreException extends RuntimeException {
//
// public RestoreException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidCommand.java
// public interface VoidCommand<T> extends Command<T, Void> {
//
// @Override
// default Void execute(T system) {
// this.executeVoid(system);
// return null;
// }
//
// void executeVoid(T system);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.prevayler.foundation.serialization.JavaSerializer;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.RestoreException;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidCommand;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.*; | System.setProperty("user.home", prevHome);
}
}
@Test
public void shouldStartTransientPrevayler() {
//WHEN
try (
final PersistenceController<StorableObject> ctrl =
PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.beTransient()
.withFolder(this.testFolder).build();) {
ctrl.execute((x) -> x.internalMap.put("myKey", "myVal"));
ctrl.close();
}
try (
final PersistenceController<StorableObject> ctrl =
PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.beTransient()
.withFolder(this.testFolder).build();) {
assertNull(ctrl.query(obj -> obj.getImmutable().get("myKey")));
ctrl.close();
}
}
| // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/RestoreException.java
// public class RestoreException extends RuntimeException {
//
// public RestoreException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidCommand.java
// public interface VoidCommand<T> extends Command<T, Void> {
//
// @Override
// default Void execute(T system) {
// this.executeVoid(system);
// return null;
// }
//
// void executeVoid(T system);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/PrevaylerBuilderTest.java
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.prevayler.foundation.serialization.JavaSerializer;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.RestoreException;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidCommand;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.*;
System.setProperty("user.home", prevHome);
}
}
@Test
public void shouldStartTransientPrevayler() {
//WHEN
try (
final PersistenceController<StorableObject> ctrl =
PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.beTransient()
.withFolder(this.testFolder).build();) {
ctrl.execute((x) -> x.internalMap.put("myKey", "myVal"));
ctrl.close();
}
try (
final PersistenceController<StorableObject> ctrl =
PrevaylerBuilder.<StorableObject>newBuilder()
.useSupplier(StorableObject::createTestObject)
.beTransient()
.withFolder(this.testFolder).build();) {
assertNull(ctrl.query(obj -> obj.getImmutable().get("myKey")));
ctrl.close();
}
}
| private static final class StrangeTransaction implements VoidCommand<StorableObject>, Serializable { |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.setblack.airomem.core.impl;
/**
* @author jratajsk
*/
public class InternalTransactionTest {
/**
* Test of executeOn method, of class InternalTransaction.
*/
@Test
public void testExecuteOn() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC)); | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java
import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.setblack.airomem.core.impl;
/**
* @author jratajsk
*/
public class InternalTransactionTest {
/**
* Test of executeOn method, of class InternalTransaction.
*/
@Test
public void testExecuteOn() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC)); | final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> x.internalMap.put("date", ctx.time.toString()); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.setblack.airomem.core.impl;
/**
* @author jratajsk
*/
public class InternalTransactionTest {
/**
* Test of executeOn method, of class InternalTransaction.
*/
@Test
public void testExecuteOn() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC)); | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java
import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.setblack.airomem.core.impl;
/**
* @author jratajsk
*/
public class InternalTransactionTest {
/**
* Test of executeOn method, of class InternalTransaction.
*/
@Test
public void testExecuteOn() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC)); | final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> x.internalMap.put("date", ctx.time.toString()); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.setblack.airomem.core.impl;
/**
* @author jratajsk
*/
public class InternalTransactionTest {
/**
* Test of executeOn method, of class InternalTransaction.
*/
@Test
public void testExecuteOn() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> x.internalMap.put("date", ctx.time.toString());
final RoyalFoodTester<StorableObject> testSystem = RoyalFoodTester.of(StorableObject.createTestObject(), true);
final InternalTransaction instance = new InternalTransaction(myCmd);
instance.executeAndQuery(testSystem, date);
assertEquals(testSystem.getFoodTester().internalMap.get("date"), time.toInstant(ZoneOffset.UTC).toString());
}
@Test
public void testWriteCheckerContext() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java
import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.setblack.airomem.core.impl;
/**
* @author jratajsk
*/
public class InternalTransactionTest {
/**
* Test of executeOn method, of class InternalTransaction.
*/
@Test
public void testExecuteOn() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> x.internalMap.put("date", ctx.time.toString());
final RoyalFoodTester<StorableObject> testSystem = RoyalFoodTester.of(StorableObject.createTestObject(), true);
final InternalTransaction instance = new InternalTransaction(myCmd);
instance.executeAndQuery(testSystem, date);
assertEquals(testSystem.getFoodTester().internalMap.get("date"), time.toInstant(ZoneOffset.UTC).toString());
}
@Test
public void testWriteCheckerContext() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> { | assertTrue(WriteChecker.hasPrevalanceContext()); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*; | @Test
public void testWriteCheckerContextClearedWhenExceptionOccured() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
final RuntimeException exception = new RuntimeException("fail");
final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> {
assertTrue(WriteChecker.hasPrevalanceContext());
assertEquals(ctx, WriteChecker.getContext());
throw exception;
};
InternalTransaction instance = new InternalTransaction(myCmd);
final RoyalFoodTester<StorableObject> testSystem = RoyalFoodTester.of(StorableObject.createTestObject());
try {
instance.executeAndQuery(testSystem, date);
} catch (Exception re) {
assertEquals(exception, re);
}
assertNull(WriteChecker.getContext());
}
/**
* Test of createContext method, of class InternalTransaction.
*/
@Test
public void testCreateContext() {
LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
VoidContextCommand<StorableObject> myCmd = (x, ctx) -> x.internalMap.put("date", ctx.time.toString());
InternalTransaction instance = new InternalTransaction(myCmd);
| // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/StorableObject.java
// public class StorableObject implements Serializable {
//
// public final HashMap<String, String> internalMap;
//
// private transient Map<String, String> immutable;
//
// public StorableObject(HashMap<String, String> intenralMap) {
// this.internalMap = intenralMap;
// this.immutable = Collections.unmodifiableMap(intenralMap);
// }
//
//
// public synchronized Map<String, String> getImmutable() {
// if (this.immutable == null) {
// this.immutable = Collections.unmodifiableMap(internalMap);
// }
// return immutable;
// }
//
// public static HashMap createTestHashMap() {
// final HashMap<String, String> result = new HashMap<>();
// for (int i = 0; i < 10; i++) {
// result.put("key:" + i, "val:" + i);
// }
// return result;
// }
//
// public static StorableObject createTestObject() {
// return new StorableObject(createTestHashMap());
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/VoidContextCommand.java
// public interface VoidContextCommand<T> extends ContextCommand<T, Void> {
//
// @Override
// default Void execute(T system, PrevalanceContext context) {
// this.executeVoid(system, context);
// return null;
// }
//
// void executeVoid(T system, PrevalanceContext context);
//
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/impl/InternalTransactionTest.java
import org.junit.Test;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.StorableObject;
import pl.setblack.airomem.core.VoidContextCommand;
import pl.setblack.airomem.core.WriteChecker;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.Date;
import static org.junit.Assert.*;
@Test
public void testWriteCheckerContextClearedWhenExceptionOccured() throws Exception {
final LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
final RuntimeException exception = new RuntimeException("fail");
final VoidContextCommand<StorableObject> myCmd = (x, ctx) -> {
assertTrue(WriteChecker.hasPrevalanceContext());
assertEquals(ctx, WriteChecker.getContext());
throw exception;
};
InternalTransaction instance = new InternalTransaction(myCmd);
final RoyalFoodTester<StorableObject> testSystem = RoyalFoodTester.of(StorableObject.createTestObject());
try {
instance.executeAndQuery(testSystem, date);
} catch (Exception re) {
assertEquals(exception, re);
}
assertNull(WriteChecker.getContext());
}
/**
* Test of createContext method, of class InternalTransaction.
*/
@Test
public void testCreateContext() {
LocalDateTime time = LocalDateTime.of(1977, Month.MAY, 20, 1, 1);
final Date date = Date.from(time.toInstant(ZoneOffset.UTC));
VoidContextCommand<StorableObject> myCmd = (x, ctx) -> x.internalMap.put("date", ctx.time.toString());
InternalTransaction instance = new InternalTransaction(myCmd);
| PrevalanceContext result = instance.createContext(date); |
airomem/airomem | airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/TransactionAnalyzer.java | // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
| import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import javax.enterprise.context.ApplicationScoped;
import javax.swing.text.html.FormSubmitEvent;
import pl.setblack.airomem.direct.OperationType; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
* Analyzes transaction kind.
*/
@ApplicationScoped
public class TransactionAnalyzer {
private Class[] WRITE_ANNOTATIONS = {};
private Class[] READ_FAST_ANNOTATIONS = {javax.ws.rs.GET.class};
| // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/TransactionAnalyzer.java
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import javax.enterprise.context.ApplicationScoped;
import javax.swing.text.html.FormSubmitEvent;
import pl.setblack.airomem.direct.OperationType;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
* Analyzes transaction kind.
*/
@ApplicationScoped
public class TransactionAnalyzer {
private Class[] WRITE_ANNOTATIONS = {};
private Class[] READ_FAST_ANNOTATIONS = {javax.ws.rs.GET.class};
| public OperationType sayTypeOf(final Method method) { |
airomem/airomem | airomem-chatsample/airomem-chatsample-web/src/main/java/pl/setblack/chatsample/web/ChatService.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/execute/ChatController.java
// @Local
// public interface ChatController {
//
// void addMessage(String nick, String message);
//
// List<MessageView> getRecentMessages();
//
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
| import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import pl.setblack.airomem.chatsample.execute.ChatController;
import pl.setblack.airomem.chatsample.view.MessageView; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.chatsample.web;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("chat")
@RequestScoped
public class ChatService {
@Context
private UriInfo context;
@Inject | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/execute/ChatController.java
// @Local
// public interface ChatController {
//
// void addMessage(String nick, String message);
//
// List<MessageView> getRecentMessages();
//
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
// Path: airomem-chatsample/airomem-chatsample-web/src/main/java/pl/setblack/chatsample/web/ChatService.java
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import pl.setblack.airomem.chatsample.execute.ChatController;
import pl.setblack.airomem.chatsample.view.MessageView;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.chatsample.web;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("chat")
@RequestScoped
public class ChatService {
@Context
private UriInfo context;
@Inject | private ChatController chatBean; |
airomem/airomem | airomem-chatsample/airomem-chatsample-web/src/main/java/pl/setblack/chatsample/web/ChatService.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/execute/ChatController.java
// @Local
// public interface ChatController {
//
// void addMessage(String nick, String message);
//
// List<MessageView> getRecentMessages();
//
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
| import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import pl.setblack.airomem.chatsample.execute.ChatController;
import pl.setblack.airomem.chatsample.view.MessageView; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.chatsample.web;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("chat")
@RequestScoped
public class ChatService {
@Context
private UriInfo context;
@Inject
private ChatController chatBean;
/**
* Creates a new instance of ChatService
*/
public ChatService() {
}
/**
* Retrieves representation of an instance of
* pl.setblack.chatsample.web.ChatService
*
* @return an instance of java.lang.String
*/
@GET
@Produces("application/json") | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/execute/ChatController.java
// @Local
// public interface ChatController {
//
// void addMessage(String nick, String message);
//
// List<MessageView> getRecentMessages();
//
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
// Path: airomem-chatsample/airomem-chatsample-web/src/main/java/pl/setblack/chatsample/web/ChatService.java
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import pl.setblack.airomem.chatsample.execute.ChatController;
import pl.setblack.airomem.chatsample.view.MessageView;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.chatsample.web;
/**
* REST Web Service
*
* @author jarek ratajski
*/
@Path("chat")
@RequestScoped
public class ChatService {
@Context
private UriInfo context;
@Inject
private ChatController chatBean;
/**
* Creates a new instance of ChatService
*/
public ChatService() {
}
/**
* Retrieves representation of an instance of
* pl.setblack.chatsample.web.ChatService
*
* @return an instance of java.lang.String
*/
@GET
@Produces("application/json") | public List<MessageView> getMessages() { |
airomem/airomem | airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContextRegistry.java | // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
| import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import pl.setblack.airomem.direct.OperationType; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
*/
@ApplicationScoped
public class ClassContextRegistry {
private final Map<Class, ClassContext> cache;
@Inject
private TransactionAnalyzer transactionAnalyzer;
public ClassContextRegistry() {
this.cache = new HashMap<>();
}
public synchronized ClassContext getContext(final Object object) {
final Class clz = object.getClass();
final ClassContext ctx = this.cache.get(clz);
if (ctx == null) {
return createAndStoreNewContext(clz);
}
return ctx;
}
private ClassContext createAndStoreNewContext(Class clz) {
final ClassContext ctx = new ClassContext(clz);
this.cache.put(clz, ctx);
return ctx;
}
| // Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContextRegistry.java
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import pl.setblack.airomem.direct.OperationType;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
*/
@ApplicationScoped
public class ClassContextRegistry {
private final Map<Class, ClassContext> cache;
@Inject
private TransactionAnalyzer transactionAnalyzer;
public ClassContextRegistry() {
this.cache = new HashMap<>();
}
public synchronized ClassContext getContext(final Object object) {
final Class clz = object.getClass();
final ClassContext ctx = this.cache.get(clz);
if (ctx == null) {
return createAndStoreNewContext(clz);
}
return ctx;
}
private ClassContext createAndStoreNewContext(Class clz) {
final ClassContext ctx = new ClassContext(clz);
this.cache.put(clz, ctx);
return ctx;
}
| public OperationType sayTypeOfMethod(final Method method) { |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/test/java/pl/setblack/airomem/chatsample/data/ChatTest.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
| /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarek ratajski
*/
public class ChatTest {
private static final String SAMPLE_CONTENT = "sample content";
private Chat chat;
private LocalDateTime time;
public ChatTest() {
}
@Before
public void setUp() {
this.chat = new Chat();
this.time = LocalDateTime.now();
| // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/test/java/pl/setblack/airomem/chatsample/data/ChatTest.java
import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarek ratajski
*/
public class ChatTest {
private static final String SAMPLE_CONTENT = "sample content";
private Chat chat;
private LocalDateTime time;
public ChatTest() {
}
@Before
public void setUp() {
this.chat = new Chat();
this.time = LocalDateTime.now();
| WriteChecker.setContext(Mockito.mock(PrevalanceContext.class));
|
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/test/java/pl/setblack/airomem/chatsample/data/ChatTest.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
| /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarek ratajski
*/
public class ChatTest {
private static final String SAMPLE_CONTENT = "sample content";
private Chat chat;
private LocalDateTime time;
public ChatTest() {
}
@Before
public void setUp() {
this.chat = new Chat();
this.time = LocalDateTime.now();
| // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/test/java/pl/setblack/airomem/chatsample/data/ChatTest.java
import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarek ratajski
*/
public class ChatTest {
private static final String SAMPLE_CONTENT = "sample content";
private Chat chat;
private LocalDateTime time;
public ChatTest() {
}
@Before
public void setUp() {
this.chat = new Chat();
this.time = LocalDateTime.now();
| WriteChecker.setContext(Mockito.mock(PrevalanceContext.class));
|
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/test/java/pl/setblack/airomem/chatsample/data/ChatTest.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
| this.chat = new Chat();
this.time = LocalDateTime.now();
WriteChecker.setContext(Mockito.mock(PrevalanceContext.class));
}
@After
public void tearDown() {
WriteChecker.clearContext();
}
@Test
public void testCreateChat() {
assertNotNull(chat);
}
@Test
public void testAddMessage() {
assertEquals(0, chat.getRecentMessages().size());
chat.addMessage("irek", SAMPLE_CONTENT, time);
assertEquals(1, chat.getRecentMessages().size());
assertEquals(SAMPLE_CONTENT, chat.getRecentMessages().get(0).getContent());
}
@Test
public void testGetLast10Messages() {
assertEquals(0, chat.getRecentMessages().size());
for (int i = 0; i < 100; i++) {
chat.addMessage("irek", SAMPLE_CONTENT + i, time);
}
| // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/test/java/pl/setblack/airomem/chatsample/data/ChatTest.java
import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
this.chat = new Chat();
this.time = LocalDateTime.now();
WriteChecker.setContext(Mockito.mock(PrevalanceContext.class));
}
@After
public void tearDown() {
WriteChecker.clearContext();
}
@Test
public void testCreateChat() {
assertNotNull(chat);
}
@Test
public void testAddMessage() {
assertEquals(0, chat.getRecentMessages().size());
chat.addMessage("irek", SAMPLE_CONTENT, time);
assertEquals(1, chat.getRecentMessages().size());
assertEquals(SAMPLE_CONTENT, chat.getRecentMessages().get(0).getContent());
}
@Test
public void testGetLast10Messages() {
assertEquals(0, chat.getRecentMessages().size());
for (int i = 0; i < 100; i++) {
chat.addMessage("irek", SAMPLE_CONTENT + i, time);
}
| List<MessageView> messages = chat.getRecentMessages();
|
airomem/airomem | airomem-core/src/main/java/pl/setblack/airomem/core/impl/InternalTransaction.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.prevayler.TransactionWithQuery;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
import java.util.Date; | /* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package pl.setblack.airomem.core.impl;
/**
* Class used internally to wrap user Command.
*
* @author jarekr
*/
class InternalTransaction<T extends Serializable, R> implements TransactionWithQuery<RoyalFoodTester<T>, R> {
private static final long serialVersionUID = 1l;
| // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/impl/InternalTransaction.java
import org.prevayler.TransactionWithQuery;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
import java.util.Date;
/* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package pl.setblack.airomem.core.impl;
/**
* Class used internally to wrap user Command.
*
* @author jarekr
*/
class InternalTransaction<T extends Serializable, R> implements TransactionWithQuery<RoyalFoodTester<T>, R> {
private static final long serialVersionUID = 1l;
| private final ContextCommand<T, R> cmd; |
airomem/airomem | airomem-core/src/main/java/pl/setblack/airomem/core/impl/InternalTransaction.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.prevayler.TransactionWithQuery;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
import java.util.Date; | /* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package pl.setblack.airomem.core.impl;
/**
* Class used internally to wrap user Command.
*
* @author jarekr
*/
class InternalTransaction<T extends Serializable, R> implements TransactionWithQuery<RoyalFoodTester<T>, R> {
private static final long serialVersionUID = 1l;
private final ContextCommand<T, R> cmd;
InternalTransaction(ContextCommand<T, R> cmd) {
this.cmd = cmd;
}
@Override
public R executeAndQuery(RoyalFoodTester<T> p, Date date) { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/impl/InternalTransaction.java
import org.prevayler.TransactionWithQuery;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
import java.util.Date;
/* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package pl.setblack.airomem.core.impl;
/**
* Class used internally to wrap user Command.
*
* @author jarekr
*/
class InternalTransaction<T extends Serializable, R> implements TransactionWithQuery<RoyalFoodTester<T>, R> {
private static final long serialVersionUID = 1l;
private final ContextCommand<T, R> cmd;
InternalTransaction(ContextCommand<T, R> cmd) {
this.cmd = cmd;
}
@Override
public R executeAndQuery(RoyalFoodTester<T> p, Date date) { | final PrevalanceContext ctx = createContext(date); |
airomem/airomem | airomem-core/src/main/java/pl/setblack/airomem/core/impl/InternalTransaction.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import org.prevayler.TransactionWithQuery;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
import java.util.Date; | /* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package pl.setblack.airomem.core.impl;
/**
* Class used internally to wrap user Command.
*
* @author jarekr
*/
class InternalTransaction<T extends Serializable, R> implements TransactionWithQuery<RoyalFoodTester<T>, R> {
private static final long serialVersionUID = 1l;
private final ContextCommand<T, R> cmd;
InternalTransaction(ContextCommand<T, R> cmd) {
this.cmd = cmd;
}
@Override
public R executeAndQuery(RoyalFoodTester<T> p, Date date) {
final PrevalanceContext ctx = createContext(date); | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/impl/InternalTransaction.java
import org.prevayler.TransactionWithQuery;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
import java.util.Date;
/* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package pl.setblack.airomem.core.impl;
/**
* Class used internally to wrap user Command.
*
* @author jarekr
*/
class InternalTransaction<T extends Serializable, R> implements TransactionWithQuery<RoyalFoodTester<T>, R> {
private static final long serialVersionUID = 1l;
private final ContextCommand<T, R> cmd;
InternalTransaction(ContextCommand<T, R> cmd) {
this.cmd = cmd;
}
@Override
public R executeAndQuery(RoyalFoodTester<T> p, Date date) {
final PrevalanceContext ctx = createContext(date); | WriteChecker.setContext(ctx); |
airomem/airomem | airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/ClassContextRegistryTest.java | // Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
| import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.SampleController;
| /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class ClassContextRegistryTest {
@Inject
private ClassContextRegistry registry;
public ClassContextRegistryTest() {
}
@Before
public void setUp() {
}
@Test
public void testGetContextReturnsSomething() {
| // Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
//
// @PersistentObject
// protected SampleObject object;
//
// public void writeMethod() {
// assertNotNull(object);
// object.setField1("changed field1");
// object.value += 14;
// }
//
// public void writeMethod2(int val1, String val2) {
// assertNotNull(object);
// object.setField1(val2);
// object.value += val1;
// }
//
// @GET
// public String readMethod() {
// assertNotNull(object);
// object.value += 7;
// return object.getField1();
// }
//
// @GET
// public String readMethod(String postfix) {
// assertNotNull(object);
// object.value += 7;
// return object.getField1() + postfix;
// }
//
// public SampleObject getObject() {
// return this.object;
// }
//
// }
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/ClassContextRegistryTest.java
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.SampleController;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.direct.impl;
/**
*
* @author jarek ratajski
*/
@RunWith(CdiRunner.class)
public class ClassContextRegistryTest {
@Inject
private ClassContextRegistry registry;
public ClassContextRegistryTest() {
}
@Before
public void setUp() {
}
@Test
public void testGetContextReturnsSomething() {
| final SampleController ctrl = new SampleController();
|
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.WriteChecker; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarekr
*/
public class Chat implements ChatView, Serializable {
private CopyOnWriteArrayList<Message> messages;
public Chat() {
this.messages = new CopyOnWriteArrayList<>();
}
public void addMessage(String nick, String content, LocalDateTime time) { | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.WriteChecker;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarekr
*/
public class Chat implements ChatView, Serializable {
private CopyOnWriteArrayList<Message> messages;
public Chat() {
this.messages = new CopyOnWriteArrayList<>();
}
public void addMessage(String nick, String content, LocalDateTime time) { | assert WriteChecker.hasPrevalanceContext(); |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.WriteChecker; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarekr
*/
public class Chat implements ChatView, Serializable {
private CopyOnWriteArrayList<Message> messages;
public Chat() {
this.messages = new CopyOnWriteArrayList<>();
}
public void addMessage(String nick, String content, LocalDateTime time) {
assert WriteChecker.hasPrevalanceContext();
final Author author = new Author(nick);
final Message msg = new Message(author, content, time);
this.messages.add(msg);
}
@Override | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.WriteChecker;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.data;
/**
*
* @author jarekr
*/
public class Chat implements ChatView, Serializable {
private CopyOnWriteArrayList<Message> messages;
public Chat() {
this.messages = new CopyOnWriteArrayList<>();
}
public void addMessage(String nick, String content, LocalDateTime time) {
assert WriteChecker.hasPrevalanceContext();
final Author author = new Author(nick);
final Message msg = new Message(author, content, time);
this.messages.add(msg);
}
@Override | public List<MessageView> getRecentMessages() { |
airomem/airomem | airomem-core/src/main/java/pl/setblack/airomem/core/impl/PersistenceControllerImpl.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import com.thoughtworks.xstream.XStream;
import org.prevayler.Prevayler;
import pl.setblack.airomem.core.*;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path; | */
@Override
public <R> R executeAndQuery(Command<ROOT, R> cmd) {
return this.executeAndQuery((ContextCommand<ROOT, R>) cmd);
}
@Override
public void execute(VoidCommand<ROOT> cmd) {
this.executeAndQuery((Command<ROOT, Void>) cmd);
}
@Override
public void execute(VoidContextCommand<ROOT> cmd) {
this.executeAndQuery((ContextCommand<ROOT, Void>) cmd);
}
private ROOT getObject() {
return this.prevayler.prevalentSystem().getWorkObject();
}
private ROOT getImmutable() {
return this.getObject();
}
@Override
public boolean isOpen() {
return this.prevayler != null;
}
public void deleteFolder() { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/impl/PersistenceControllerImpl.java
import com.thoughtworks.xstream.XStream;
import org.prevayler.Prevayler;
import pl.setblack.airomem.core.*;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path;
*/
@Override
public <R> R executeAndQuery(Command<ROOT, R> cmd) {
return this.executeAndQuery((ContextCommand<ROOT, R>) cmd);
}
@Override
public void execute(VoidCommand<ROOT> cmd) {
this.executeAndQuery((Command<ROOT, Void>) cmd);
}
@Override
public void execute(VoidContextCommand<ROOT> cmd) {
this.executeAndQuery((ContextCommand<ROOT, Void>) cmd);
}
private ROOT getObject() {
return this.prevayler.prevalentSystem().getWorkObject();
}
private ROOT getImmutable() {
return this.getObject();
}
@Override
public boolean isOpen() {
return this.prevayler != null;
}
public void deleteFolder() { | PersistenceDiskHelper.delete(this.path); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/sequnce/SequenceSystem.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
| import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable; | /*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.sequnce;
/**
* @author jarekr
*/
public class SequenceSystem implements Serializable {
private final Sequence seq = new Sequence();
private long number;
public Sequence getSequence() {
return seq;
}
public long getNumber() {
return this.number;
}
public void setNumber(long id) { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
//
// private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
//
// public static void setContext(final PrevalanceContext ctx) {
// assert !hasPrevalanceContext() : "Context was initialized before";
// CONTEXT_STORE.set(ctx);
// }
//
// public static PrevalanceContext getContext() {
// return CONTEXT_STORE.get();
// }
//
// public static void clearContext() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// CONTEXT_STORE.remove();
// }
//
// public static boolean hasPrevalanceContext() {
// return CONTEXT_STORE.get() != null;
// }
//
// public static void enterSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert !getContext().safe : "context cannot be safe before";
// CONTEXT_STORE.set(getContext().safe());
// }
//
// public static void leaveSafe() {
// assert hasPrevalanceContext() : "Context has to be initialized first";
// assert getContext().safe : "context must be safe before";
//
// CONTEXT_STORE.set(getContext().unsafe());
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/sequnce/SequenceSystem.java
import pl.setblack.airomem.core.WriteChecker;
import java.io.Serializable;
/*
* Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
package pl.setblack.airomem.core.sequnce;
/**
* @author jarekr
*/
public class SequenceSystem implements Serializable {
private final Sequence seq = new Sequence();
private long number;
public Sequence getSequence() {
return seq;
}
public long getNumber() {
return this.number;
}
public void setNumber(long id) { | assert WriteChecker.hasPrevalanceContext(); |
airomem/airomem | airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
| import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician; | this.elem.storeValue(target, system);
}
private void clean(Object target) {
this.elem.cleanValue(target);
}
private static BeanManager getBeanManager() {
return Politician.beatAroundTheBush(()
-> (BeanManager) InitialContext.doLookup("java:comp/BeanManager"));
}
private static Object instantiateBean(final Class cls) throws IllegalStateException {
final BeanManager beanManager = getBeanManager();
for (Bean<?> bean : beanManager.getBeans(cls)) {
final CreationalContext context = beanManager.createCreationalContext(bean);
return beanManager.getReference(bean, cls, context);
}
throw new IllegalStateException("no bean of class" + cls);
}
private static ClassContextRegistry findRegistry() {
return (ClassContextRegistry) instantiateBean(ClassContextRegistry.class
);
}
public Object performTransaction(InvocationContext ctx) {
final Method method = ctx.getMethod(); | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician;
this.elem.storeValue(target, system);
}
private void clean(Object target) {
this.elem.cleanValue(target);
}
private static BeanManager getBeanManager() {
return Politician.beatAroundTheBush(()
-> (BeanManager) InitialContext.doLookup("java:comp/BeanManager"));
}
private static Object instantiateBean(final Class cls) throws IllegalStateException {
final BeanManager beanManager = getBeanManager();
for (Bean<?> bean : beanManager.getBeans(cls)) {
final CreationalContext context = beanManager.createCreationalContext(bean);
return beanManager.getReference(bean, cls, context);
}
throw new IllegalStateException("no bean of class" + cls);
}
private static ClassContextRegistry findRegistry() {
return (ClassContextRegistry) instantiateBean(ClassContextRegistry.class
);
}
public Object performTransaction(InvocationContext ctx) {
final Method method = ctx.getMethod(); | final OperationType opType = findRegistry().sayTypeOfMethod(method); |
airomem/airomem | airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
| import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician; | }
throw new IllegalStateException("no bean of class" + cls);
}
private static ClassContextRegistry findRegistry() {
return (ClassContextRegistry) instantiateBean(ClassContextRegistry.class
);
}
public Object performTransaction(InvocationContext ctx) {
final Method method = ctx.getMethod();
final OperationType opType = findRegistry().sayTypeOfMethod(method);
if (opType == OperationType.WRITE) {
return this.performTransaction(ctx.getTarget(), method, ctx.getParameters());
} else {
try {
final SimpleController controller = PrevaylerRegister.getInstance().getController(elem.getTargetType(), elem.getName());
inject(ctx.getTarget(), controller.query(immutable -> immutable));
return Politician.beatAroundTheBush(() -> ctx.proceed());
} finally {
clean(ctx.getTarget());
}
}
}
| // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician;
}
throw new IllegalStateException("no bean of class" + cls);
}
private static ClassContextRegistry findRegistry() {
return (ClassContextRegistry) instantiateBean(ClassContextRegistry.class
);
}
public Object performTransaction(InvocationContext ctx) {
final Method method = ctx.getMethod();
final OperationType opType = findRegistry().sayTypeOfMethod(method);
if (opType == OperationType.WRITE) {
return this.performTransaction(ctx.getTarget(), method, ctx.getParameters());
} else {
try {
final SimpleController controller = PrevaylerRegister.getInstance().getController(elem.getTargetType(), elem.getName());
inject(ctx.getTarget(), controller.query(immutable -> immutable));
return Politician.beatAroundTheBush(() -> ctx.proceed());
} finally {
clean(ctx.getTarget());
}
}
}
| private static class WraperTransaction implements ContextCommand<Object, Object>, Serializable { |
airomem/airomem | airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
| import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician; | private final String targetClass;
private final String methodName;
private String[] paramClasses;
private final Object[] arguments;
public WraperTransaction(String targetClass, final Method method, final Object[] args) {
this.targetClass = targetClass;
this.methodName = method.getName();
this.arguments = args;
storeParams(method);
}
private Object instantiateTarget() throws ClassNotFoundException {
final Class cls = Class.forName(this.targetClass);
return instantiateBean(cls);
}
private Class[] getParams() {
final Class[] result = new Class[this.paramClasses.length];
for (int i = 0; i < result.length; i++) {
final String className = this.paramClasses[i];
result[i] = Politician.beatAroundTheBush(() -> ClassUtils.getClass(className));
}
return result;
}
@Override | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician;
private final String targetClass;
private final String methodName;
private String[] paramClasses;
private final Object[] arguments;
public WraperTransaction(String targetClass, final Method method, final Object[] args) {
this.targetClass = targetClass;
this.methodName = method.getName();
this.arguments = args;
storeParams(method);
}
private Object instantiateTarget() throws ClassNotFoundException {
final Class cls = Class.forName(this.targetClass);
return instantiateBean(cls);
}
private Class[] getParams() {
final Class[] result = new Class[this.paramClasses.length];
for (int i = 0; i < result.length; i++) {
final String className = this.paramClasses[i];
result[i] = Politician.beatAroundTheBush(() -> ClassUtils.getClass(className));
}
return result;
}
@Override | public Object execute(Object system, PrevalanceContext context |
airomem/airomem | airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
| import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician; | private final String methodName;
private String[] paramClasses;
private final Object[] arguments;
public WraperTransaction(String targetClass, final Method method, final Object[] args) {
this.targetClass = targetClass;
this.methodName = method.getName();
this.arguments = args;
storeParams(method);
}
private Object instantiateTarget() throws ClassNotFoundException {
final Class cls = Class.forName(this.targetClass);
return instantiateBean(cls);
}
private Class[] getParams() {
final Class[] result = new Class[this.paramClasses.length];
for (int i = 0; i < result.length; i++) {
final String className = this.paramClasses[i];
result[i] = Politician.beatAroundTheBush(() -> ClassUtils.getClass(className));
}
return result;
}
@Override
public Object execute(Object system, PrevalanceContext context
) { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/ContextCommand.java
// @FunctionalInterface
// public interface ContextCommand<T, R> extends Serializable {
//
// /**
// * @param system reference to mutable system
// * @param context context info (such as date)
// */
// R execute(T system, PrevalanceContext context);
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
//
// /**
// * Use this time object whenewer actual time was needed in command.
// */
// public final Instant time;
//
// public final boolean safe;
//
// public PrevalanceContext(final Date date) {
// this(date.toInstant(), false);
// }
//
// private PrevalanceContext(final Instant time, final boolean safe) {
// this.time = time;
// this.safe = safe;
// }
//
// public PrevalanceContext safe() {
// return new PrevalanceContext(this.time, true);
// }
//
// public PrevalanceContext unsafe() {
// return new PrevalanceContext(this.time, false);
// }
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
//
// WRITE,
// READ_FAST,
// READ_COMMITTED;
// }
//
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/PersistenceInterceptor.java
// @Interceptor
// @Persistent
// public class PersistenceInterceptor {
//
// private static final ThreadLocal<Boolean> MARKER = new ThreadLocal<>();
//
// @Inject
// private ClassContextRegistry registry;
//
// @AroundInvoke
// public Object preparePersistence(InvocationContext ctx) {
// try {
// if (!Boolean.TRUE.equals(MARKER.get())) {
// final ClassContext classContext = registry.getContext(ctx.getTarget());
// return classContext.performTransaction(ctx);
//
// } else {
// return Politician.beatAroundTheBush(() -> ctx.proceed());
// }
// } finally {
// MARKER.remove();
// }
// }
//
// public static void setMarker() {
// MARKER.set(Boolean.TRUE);
// }
// }
// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContext.java
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.InvocationContext;
import javax.naming.InitialContext;
import org.apache.commons.lang.ClassUtils;
import pl.setblack.airomem.core.ContextCommand;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.SimpleController;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.PersistenceInterceptor;
import pl.setblack.airomem.direct.PersistentObject;
import pl.setblack.badass.Politician;
private final String methodName;
private String[] paramClasses;
private final Object[] arguments;
public WraperTransaction(String targetClass, final Method method, final Object[] args) {
this.targetClass = targetClass;
this.methodName = method.getName();
this.arguments = args;
storeParams(method);
}
private Object instantiateTarget() throws ClassNotFoundException {
final Class cls = Class.forName(this.targetClass);
return instantiateBean(cls);
}
private Class[] getParams() {
final Class[] result = new Class[this.paramClasses.length];
for (int i = 0; i < result.length; i++) {
final String className = this.paramClasses[i];
result[i] = Politician.beatAroundTheBush(() -> ClassUtils.getClass(className));
}
return result;
}
@Override
public Object execute(Object system, PrevalanceContext context
) { | PersistenceInterceptor.setMarker(); |
airomem/airomem | airomem-core/src/test/java/pl/setblack/airomem/core/builders/AbstractPrevaylerTest.java | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
| import org.junit.After;
import org.junit.Before;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.io.Serializable; | this.origUserHome = System.getProperty("user.home");
System.setProperty("user.home", localFolder.getAbsolutePath());
AbstractPrevaylerTest.deletePrevaylerFolder();
this.persistenceController = PrevaylerBuilder
.<T>newBuilder()
.withinUserFolder("test")
.forceOverwrite(true)
.useSupplier(() -> createSystem())
.build();
}
@After
public void tearDown() {
this.persistenceController.close();
AbstractPrevaylerTest.deletePrevaylerFolder();
System.setProperty("user.home", origUserHome);
}
protected void reloadController(Class<T> type) {
this.persistenceController.close();
this.persistenceController = PrevaylerBuilder
.<T>newBuilder()
.withinUserFolder("test")
.forceOverwrite(false)
.build();
}
static void deletePrevaylerFolder() { | // Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
//
// public static final String STORAGE_FOLDER = "prevayler";
//
// PersistenceDiskHelper() {
// throw new UnsupportedOperationException("do not create util classes");
// }
//
// public static String calcFolderName(final Path path) {
// return path.toString();
// }
//
// /**
// * Check if save of given name exists.
// */
// public static boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static void delete(Path path) {
// if (exists(path)) {
// Politician.beatAroundTheBush(() -> {
// FileUtils.deleteDirectory(path.toFile());
// });
// }
// }
//
//
// public static Path calcUserPath(String folderName) {
// final String userFolder = System.getProperty("user.home");
// return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
// }
//
// }
// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/AbstractPrevaylerTest.java
import org.junit.After;
import org.junit.Before;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import java.io.File;
import java.io.Serializable;
this.origUserHome = System.getProperty("user.home");
System.setProperty("user.home", localFolder.getAbsolutePath());
AbstractPrevaylerTest.deletePrevaylerFolder();
this.persistenceController = PrevaylerBuilder
.<T>newBuilder()
.withinUserFolder("test")
.forceOverwrite(true)
.useSupplier(() -> createSystem())
.build();
}
@After
public void tearDown() {
this.persistenceController.close();
AbstractPrevaylerTest.deletePrevaylerFolder();
System.setProperty("user.home", origUserHome);
}
protected void reloadController(Class<T> type) {
this.persistenceController.close();
this.persistenceController = PrevaylerBuilder
.<T>newBuilder()
.withinUserFolder("test")
.forceOverwrite(false)
.build();
}
static void deletePrevaylerFolder() { | PersistenceDiskHelper.delete(PersistenceDiskHelper.calcUserPath("test")); |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java | // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
| import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| private PersistenceController<DataRoot<ChatView, Chat>, ChatView> controller; |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java | // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
| import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| private PersistenceController<DataRoot<ChatView, Chat>, ChatView> controller; |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java | // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
| import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| private PersistenceController<DataRoot<ChatView, Chat>, ChatView> controller; |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java | // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
| import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
| private PersistenceController<DataRoot<ChatView, Chat>, ChatView> controller; |
airomem/airomem | airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java | // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
| import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot; | /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
private PersistenceController<DataRoot<ChatView, Chat>, ChatView> controller;
@PostConstruct
void initController() {
final PersistenceFactory factory = new PersistenceFactory();
controller = factory.initOptional("chat", () -> new DataRoot<>(new Chat()));
}
@Override
public void addMessage(String nick, String message) {
controller.execute((chat, ctx) -> {
chat.getDataObject().addMessage(nick, message, LocalDateTime.ofInstant(ctx.time, ZoneId.systemDefault()));
if (nick.equals("badguy")) {
throw new SecurityException();
}
});
}
@Override | // Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/data/Chat.java
// public class Chat implements ChatView, Serializable {
//
// private CopyOnWriteArrayList<Message> messages;
//
// public Chat() {
// this.messages = new CopyOnWriteArrayList<>();
// }
//
// public void addMessage(String nick, String content, LocalDateTime time) {
// assert WriteChecker.hasPrevalanceContext();
// final Author author = new Author(nick);
// final Message msg = new Message(author, content, time);
// this.messages.add(msg);
//
// }
//
// @Override
// public List<MessageView> getRecentMessages() {
// int count = this.messages.size();
// final List<MessageView> res = this.messages.stream().skip(Math.max(count - 10, 0))
// .limit(10)
// .collect(Collectors.toList());
// return res;
// }
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PersistenceController.java
// public interface PersistenceController<ROOT extends Serializable> extends AutoCloseable {
//
// void close();
//
// void shut();
//
// /**
// * Query system (immutable view of it).
// * <p>
// * Few things to remember: 1. if operations done on system (using query) do
// * make some changes they will not be preserved (for long) 2. it is possible
// * to return any object from domain (including ROOT root) and perform
// * operations later on (but the more You do inside Query the safer).
// *
// * @param <RESULT> result of query
// * @param query lambda (or query implementation) with operations
// * @return calculated result
// */
// <RESULT> RESULT query(Query<ROOT, RESULT> query);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(ContextCommand<ROOT, R> cmd);
//
// /**
// * Perform command on system.
// * <p>
// * Inside command can be any code doing any changes. Such changes are
// * guaranteed to be preserved (if only command ended without exception).
// *
// * @param cmd
// */
// <R> R executeAndQuery(Command<ROOT, R> cmd);
//
// void execute(VoidCommand<ROOT> cmd);
//
// void execute(VoidContextCommand<ROOT> cmd);
//
// boolean isOpen();
//
// void erase();
//
// void snapshot();
//
// void snapshotXML(Path xmlFile) throws IOException;
// }
//
// Path: airomem-core/src/main/java/pl/setblack/airomem/data/DataRoot.java
// public class DataRoot<DATA> implements Serializable {
// private static final long serialVersionUID = 1l;
// private final DATA persistentObject;
//
// public DataRoot(DATA persistentObject) {
// this.persistentObject = persistentObject;
// }
//
// public DATA getDataObject() {
// return persistentObject;
// }
//
// }
// Path: airomem-chatsample/airomem-chatsample-data/src/main/java/pl/setblack/airomem/chatsample/execute/ChatControllerImpl.java
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import pl.setblack.airomem.chatsample.data.Chat;
import pl.setblack.airomem.chatsample.view.ChatView;
import pl.setblack.airomem.chatsample.view.MessageView;
import pl.setblack.airomem.core.PersistenceController;
import pl.setblack.airomem.core.builders.PersistenceFactory;
import pl.setblack.airomem.data.DataRoot;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarekr
*/
@ApplicationScoped
public class ChatControllerImpl implements ChatController {
private PersistenceController<DataRoot<ChatView, Chat>, ChatView> controller;
@PostConstruct
void initController() {
final PersistenceFactory factory = new PersistenceFactory();
controller = factory.initOptional("chat", () -> new DataRoot<>(new Chat()));
}
@Override
public void addMessage(String nick, String message) {
controller.execute((chat, ctx) -> {
chat.getDataObject().addMessage(nick, message, LocalDateTime.ofInstant(ctx.time, ZoneId.systemDefault()));
if (nick.equals("badguy")) {
throw new SecurityException();
}
});
}
@Override | public List<MessageView> getRecentMessages() { |
airomem/airomem | airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/execute/ChatController.java | // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
| import pl.setblack.airomem.chatsample.view.MessageView;
import java.util.List;
import javax.ejb.Local;
import pl.setblack.airomem.chatsample.view.ChatView;
| /*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarek ratajski
*/
@Local
public interface ChatController {
void addMessage(String nick, String message);
| // Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/ChatView.java
// public interface ChatView {
//
// List<MessageView> getRecentMessages();
// }
//
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/view/MessageView.java
// @XmlRootElement
// public interface MessageView {
//
// @XmlElement
// String getContent();
//
// @XmlElement
// AuthorView getAuthorView();
//
// @XmlAttribute
// LocalDateTime getTime();
//
// String getAuthorNick();
// }
// Path: airomem-chatsample/airomem-chatsample-view/src/main/java/pl/setblack/airomem/chatsample/execute/ChatController.java
import pl.setblack.airomem.chatsample.view.MessageView;
import java.util.List;
import javax.ejb.Local;
import pl.setblack.airomem.chatsample.view.ChatView;
/*
* Created by Jarek Ratajski
*/
package pl.setblack.airomem.chatsample.execute;
/**
*
* @author jarek ratajski
*/
@Local
public interface ChatController {
void addMessage(String nick, String message);
| List<MessageView> getRecentMessages();
|
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyGroupManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files; | package com.github.config.service.web.mb;
/**
* 属性分组请求处理
*/
@ManagedBean(name = "propertyGroupMB")
@ViewScoped | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyGroupManagedBean.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
package com.github.config.service.web.mb;
/**
* 属性分组请求处理
*/
@ManagedBean(name = "propertyGroupMB")
@ViewScoped | public class PropertyGroupManagedBean implements Serializable, IObserver { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyGroupManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files; | package com.github.config.service.web.mb;
/**
* 属性分组请求处理
*/
@ManagedBean(name = "propertyGroupMB")
@ViewScoped
public class PropertyGroupManagedBean implements Serializable, IObserver {
private static final long serialVersionUID = -884408941213688603L;
@ManagedProperty(value = "#{nodeService}") | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyGroupManagedBean.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
package com.github.config.service.web.mb;
/**
* 属性分组请求处理
*/
@ManagedBean(name = "propertyGroupMB")
@ViewScoped
public class PropertyGroupManagedBean implements Serializable, IObserver {
private static final long serialVersionUID = -884408941213688603L;
@ManagedProperty(value = "#{nodeService}") | private INodeService nodeService; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyGroupManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files; | /**
* 上传配置
*/
public void propertyGroupUpload(FileUploadEvent event) {
String fileName = event.getFile().getFileName();
LOGGER.info("Deal uploaded file: {}", fileName);
String group = Files.getNameWithoutExtension(fileName);
InputStream inputstream = null;
try {
inputstream = event.getFile().getInputstream();
savePropertyGroup(fileName, group, inputstream);
}
catch (IOException e) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, "File parse error.", fileName));
LOGGER.error("Upload File Exception.", e);
}
finally {
if (inputstream != null) {
try {
inputstream.close();
}
catch (IOException e) {
// DO NOTHING
}
}
}
}
private void savePropertyGroup(String fileName, String group, InputStream inputstream) throws IOException { | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyGroupManagedBean.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
/**
* 上传配置
*/
public void propertyGroupUpload(FileUploadEvent event) {
String fileName = event.getFile().getFileName();
LOGGER.info("Deal uploaded file: {}", fileName);
String group = Files.getNameWithoutExtension(fileName);
InputStream inputstream = null;
try {
inputstream = event.getFile().getInputstream();
savePropertyGroup(fileName, group, inputstream);
}
catch (IOException e) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, "File parse error.", fileName));
LOGGER.error("Upload File Exception.", e);
}
finally {
if (inputstream != null) {
try {
inputstream.close();
}
catch (IOException e) {
// DO NOTHING
}
}
}
}
private void savePropertyGroup(String fileName, String group, InputStream inputstream) throws IOException { | List<PropertyItemVO> items = parseInputFile(inputstream); |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/register/zookeeper/NestedZookeeperServers.java | // Path: elastic-config-core/src/main/java/com/github/config/exception/RegisterExceptionHandler.java
// @Slf4j
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class RegisterExceptionHandler {
//
// /**
// * 处理掉中断和连接失效异常并继续抛出RegisterException.
// *
// * @param cause 待处理的异常.
// */
// public static void handleException(final Exception cause) {
// if (isIgnoredException(cause) || isIgnoredException(cause.getCause())) {
// log.debug("Elastic config: ignored exception for: {}", cause.getMessage());
// }
// else if (cause instanceof InterruptedException) {
// Thread.currentThread().interrupt();
// }
// else {
// throw new RegisterException(cause);
// }
// }
//
// private static boolean isIgnoredException(final Throwable cause) {
// return null != cause
// && (cause instanceof ConnectionLossException || cause instanceof NoNodeException || cause instanceof NodeExistsException);
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.curator.test.TestingServer;
import com.github.config.exception.RegisterExceptionHandler; | package com.github.config.register.zookeeper;
/**
* 内嵌的Zookeeper服务器.
* <p>
* 可以根据不同的端口号启动多个Zookeeper服务. 但每个相同的端口号共用一个服务实例.
* </p>
*
* @author ZhangWei
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class NestedZookeeperServers {
private static NestedZookeeperServers instance = new NestedZookeeperServers();
private static ConcurrentMap<Integer, TestingServer> nestedServers = new ConcurrentHashMap<>();
/**
* 获取单例实例.
*
* @return 单例实例
*/
public static NestedZookeeperServers getInstance() {
return instance;
}
/**
* 启动内嵌的Zookeeper服务.
*
* @param port 端口号
* <p>
* 如果该端口号的Zookeeper服务未启动, 则启动服务. 如果该端口号的Zookeeper服务已启动, 则不做任何操作.
* </p>
*/
public synchronized void startServerIfNotStarted(final int port, final String dataDir) {
if (!nestedServers.containsKey(port)) {
TestingServer testingServer = null;
try {
testingServer = new TestingServer(port, new File(dataDir));
}
catch (final Exception ex) { | // Path: elastic-config-core/src/main/java/com/github/config/exception/RegisterExceptionHandler.java
// @Slf4j
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class RegisterExceptionHandler {
//
// /**
// * 处理掉中断和连接失效异常并继续抛出RegisterException.
// *
// * @param cause 待处理的异常.
// */
// public static void handleException(final Exception cause) {
// if (isIgnoredException(cause) || isIgnoredException(cause.getCause())) {
// log.debug("Elastic config: ignored exception for: {}", cause.getMessage());
// }
// else if (cause instanceof InterruptedException) {
// Thread.currentThread().interrupt();
// }
// else {
// throw new RegisterException(cause);
// }
// }
//
// private static boolean isIgnoredException(final Throwable cause) {
// return null != cause
// && (cause instanceof ConnectionLossException || cause instanceof NoNodeException || cause instanceof NodeExistsException);
// }
// }
// Path: elastic-config-core/src/main/java/com/github/config/register/zookeeper/NestedZookeeperServers.java
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.curator.test.TestingServer;
import com.github.config.exception.RegisterExceptionHandler;
package com.github.config.register.zookeeper;
/**
* 内嵌的Zookeeper服务器.
* <p>
* 可以根据不同的端口号启动多个Zookeeper服务. 但每个相同的端口号共用一个服务实例.
* </p>
*
* @author ZhangWei
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class NestedZookeeperServers {
private static NestedZookeeperServers instance = new NestedZookeeperServers();
private static ConcurrentMap<Integer, TestingServer> nestedServers = new ConcurrentHashMap<>();
/**
* 获取单例实例.
*
* @return 单例实例
*/
public static NestedZookeeperServers getInstance() {
return instance;
}
/**
* 启动内嵌的Zookeeper服务.
*
* @param port 端口号
* <p>
* 如果该端口号的Zookeeper服务未启动, 则启动服务. 如果该端口号的Zookeeper服务已启动, 则不做任何操作.
* </p>
*/
public synchronized void startServerIfNotStarted(final int port, final String dataDir) {
if (!nestedServers.containsKey(port)) {
TestingServer testingServer = null;
try {
testingServer = new TestingServer(port, new File(dataDir));
}
catch (final Exception ex) { | RegisterExceptionHandler.handleException(ex); |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/NodeService.java | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/INodeDao.java
// public interface INodeDao {
//
// /**
// * 查找子属性
// *
// * @param node
// * @return property item list
// */
// List<PropertyItem> findProperties(String node);
//
// /**
// * 查找子结点
// *
// * @param node
// * @return string list
// */
// List<String> listChildren(String node);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IPropertyDao.java
// public interface IPropertyDao {
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
//
// }
| import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.zkdao.INodeDao;
import com.github.config.service.zkdao.IPropertyDao; | package com.github.config.service;
@Service
public class NodeService implements INodeService, Serializable {
private static final long serialVersionUID = 8144546191743589658L;
@Autowired | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/INodeDao.java
// public interface INodeDao {
//
// /**
// * 查找子属性
// *
// * @param node
// * @return property item list
// */
// List<PropertyItem> findProperties(String node);
//
// /**
// * 查找子结点
// *
// * @param node
// * @return string list
// */
// List<String> listChildren(String node);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IPropertyDao.java
// public interface IPropertyDao {
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/NodeService.java
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.zkdao.INodeDao;
import com.github.config.service.zkdao.IPropertyDao;
package com.github.config.service;
@Service
public class NodeService implements INodeService, Serializable {
private static final long serialVersionUID = 8144546191743589658L;
@Autowired | private INodeDao nodeDao; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/NodeService.java | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/INodeDao.java
// public interface INodeDao {
//
// /**
// * 查找子属性
// *
// * @param node
// * @return property item list
// */
// List<PropertyItem> findProperties(String node);
//
// /**
// * 查找子结点
// *
// * @param node
// * @return string list
// */
// List<String> listChildren(String node);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IPropertyDao.java
// public interface IPropertyDao {
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
//
// }
| import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.zkdao.INodeDao;
import com.github.config.service.zkdao.IPropertyDao; | package com.github.config.service;
@Service
public class NodeService implements INodeService, Serializable {
private static final long serialVersionUID = 8144546191743589658L;
@Autowired
private INodeDao nodeDao;
@Autowired | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/INodeDao.java
// public interface INodeDao {
//
// /**
// * 查找子属性
// *
// * @param node
// * @return property item list
// */
// List<PropertyItem> findProperties(String node);
//
// /**
// * 查找子结点
// *
// * @param node
// * @return string list
// */
// List<String> listChildren(String node);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IPropertyDao.java
// public interface IPropertyDao {
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/NodeService.java
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.zkdao.INodeDao;
import com.github.config.service.zkdao.IPropertyDao;
package com.github.config.service;
@Service
public class NodeService implements INodeService, Serializable {
private static final long serialVersionUID = 8144546191743589658L;
@Autowired
private INodeDao nodeDao;
@Autowired | private IPropertyDao propertyDao; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/NodeService.java | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/INodeDao.java
// public interface INodeDao {
//
// /**
// * 查找子属性
// *
// * @param node
// * @return property item list
// */
// List<PropertyItem> findProperties(String node);
//
// /**
// * 查找子结点
// *
// * @param node
// * @return string list
// */
// List<String> listChildren(String node);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IPropertyDao.java
// public interface IPropertyDao {
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
//
// }
| import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.zkdao.INodeDao;
import com.github.config.service.zkdao.IPropertyDao; | package com.github.config.service;
@Service
public class NodeService implements INodeService, Serializable {
private static final long serialVersionUID = 8144546191743589658L;
@Autowired
private INodeDao nodeDao;
@Autowired
private IPropertyDao propertyDao;
@Override | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/INodeDao.java
// public interface INodeDao {
//
// /**
// * 查找子属性
// *
// * @param node
// * @return property item list
// */
// List<PropertyItem> findProperties(String node);
//
// /**
// * 查找子结点
// *
// * @param node
// * @return string list
// */
// List<String> listChildren(String node);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IPropertyDao.java
// public interface IPropertyDao {
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/NodeService.java
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.zkdao.INodeDao;
import com.github.config.service.zkdao.IPropertyDao;
package com.github.config.service;
@Service
public class NodeService implements INodeService, Serializable {
private static final long serialVersionUID = 8144546191743589658L;
@Autowired
private INodeDao nodeDao;
@Autowired
private IPropertyDao propertyDao;
@Override | public List<PropertyItem> findProperties(String node) { |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/namespace/handler/RegNamespaceHandler.java | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
// public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
//
// BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
// groupBuilder.addConstructorArgValue(createConfiguration(element));
// groupBuilder.setDestroyMethodName("close");
//
// return groupBuilder.getBeanDefinition();
// }
//
// private SpringZookeeperConfiguration createConfiguration(final Element element) {
// SpringZookeeperConfiguration result = new SpringZookeeperConfiguration(
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.NAMESPACE_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.PROJECT_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.VERSION_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_ATTRIBUTE));
// result.setRefresh(element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_REFRESH));
// return result;
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
// public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
// BeanDefinitionBuilder factory = BeanDefinitionBuilder
// .rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
// BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(RegistryPropertySources.class);
// definitionBuilder.addConstructorArgReference(element
// .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
// factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition());
// factory.addPropertyValue("order", "-1");
// return factory.getBeanDefinition();
// }
// }
| import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
import com.github.config.spring.namespace.parser.ConfigGroupBeanDefinitionParser;
import com.github.config.spring.namespace.parser.PlaceholderBeanDefinitionParser; | package com.github.config.spring.namespace.handler;
/**
* 注册中心的命名空间处理器.
*
* @author ZhangWei
*/
public class RegNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() { | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
// public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
//
// BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
// groupBuilder.addConstructorArgValue(createConfiguration(element));
// groupBuilder.setDestroyMethodName("close");
//
// return groupBuilder.getBeanDefinition();
// }
//
// private SpringZookeeperConfiguration createConfiguration(final Element element) {
// SpringZookeeperConfiguration result = new SpringZookeeperConfiguration(
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.NAMESPACE_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.PROJECT_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.VERSION_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_ATTRIBUTE));
// result.setRefresh(element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_REFRESH));
// return result;
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
// public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
// BeanDefinitionBuilder factory = BeanDefinitionBuilder
// .rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
// BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(RegistryPropertySources.class);
// definitionBuilder.addConstructorArgReference(element
// .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
// factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition());
// factory.addPropertyValue("order", "-1");
// return factory.getBeanDefinition();
// }
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/handler/RegNamespaceHandler.java
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
import com.github.config.spring.namespace.parser.ConfigGroupBeanDefinitionParser;
import com.github.config.spring.namespace.parser.PlaceholderBeanDefinitionParser;
package com.github.config.spring.namespace.handler;
/**
* 注册中心的命名空间处理器.
*
* @author ZhangWei
*/
public class RegNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() { | registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_CONFIG_ELEMENT, |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/namespace/handler/RegNamespaceHandler.java | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
// public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
//
// BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
// groupBuilder.addConstructorArgValue(createConfiguration(element));
// groupBuilder.setDestroyMethodName("close");
//
// return groupBuilder.getBeanDefinition();
// }
//
// private SpringZookeeperConfiguration createConfiguration(final Element element) {
// SpringZookeeperConfiguration result = new SpringZookeeperConfiguration(
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.NAMESPACE_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.PROJECT_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.VERSION_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_ATTRIBUTE));
// result.setRefresh(element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_REFRESH));
// return result;
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
// public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
// BeanDefinitionBuilder factory = BeanDefinitionBuilder
// .rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
// BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(RegistryPropertySources.class);
// definitionBuilder.addConstructorArgReference(element
// .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
// factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition());
// factory.addPropertyValue("order", "-1");
// return factory.getBeanDefinition();
// }
// }
| import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
import com.github.config.spring.namespace.parser.ConfigGroupBeanDefinitionParser;
import com.github.config.spring.namespace.parser.PlaceholderBeanDefinitionParser; | package com.github.config.spring.namespace.handler;
/**
* 注册中心的命名空间处理器.
*
* @author ZhangWei
*/
public class RegNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_CONFIG_ELEMENT, | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
// public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
//
// BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
// groupBuilder.addConstructorArgValue(createConfiguration(element));
// groupBuilder.setDestroyMethodName("close");
//
// return groupBuilder.getBeanDefinition();
// }
//
// private SpringZookeeperConfiguration createConfiguration(final Element element) {
// SpringZookeeperConfiguration result = new SpringZookeeperConfiguration(
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.NAMESPACE_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.PROJECT_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.VERSION_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_ATTRIBUTE));
// result.setRefresh(element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_REFRESH));
// return result;
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
// public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
// BeanDefinitionBuilder factory = BeanDefinitionBuilder
// .rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
// BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(RegistryPropertySources.class);
// definitionBuilder.addConstructorArgReference(element
// .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
// factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition());
// factory.addPropertyValue("order", "-1");
// return factory.getBeanDefinition();
// }
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/handler/RegNamespaceHandler.java
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
import com.github.config.spring.namespace.parser.ConfigGroupBeanDefinitionParser;
import com.github.config.spring.namespace.parser.PlaceholderBeanDefinitionParser;
package com.github.config.spring.namespace.handler;
/**
* 注册中心的命名空间处理器.
*
* @author ZhangWei
*/
public class RegNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_CONFIG_ELEMENT, | new ConfigGroupBeanDefinitionParser()); |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/namespace/handler/RegNamespaceHandler.java | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
// public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
//
// BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
// groupBuilder.addConstructorArgValue(createConfiguration(element));
// groupBuilder.setDestroyMethodName("close");
//
// return groupBuilder.getBeanDefinition();
// }
//
// private SpringZookeeperConfiguration createConfiguration(final Element element) {
// SpringZookeeperConfiguration result = new SpringZookeeperConfiguration(
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.NAMESPACE_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.PROJECT_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.VERSION_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_ATTRIBUTE));
// result.setRefresh(element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_REFRESH));
// return result;
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
// public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
// BeanDefinitionBuilder factory = BeanDefinitionBuilder
// .rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
// BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(RegistryPropertySources.class);
// definitionBuilder.addConstructorArgReference(element
// .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
// factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition());
// factory.addPropertyValue("order", "-1");
// return factory.getBeanDefinition();
// }
// }
| import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
import com.github.config.spring.namespace.parser.ConfigGroupBeanDefinitionParser;
import com.github.config.spring.namespace.parser.PlaceholderBeanDefinitionParser; | package com.github.config.spring.namespace.handler;
/**
* 注册中心的命名空间处理器.
*
* @author ZhangWei
*/
public class RegNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_CONFIG_ELEMENT,
new ConfigGroupBeanDefinitionParser());
registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_PLACEHOLDER_ELEMENT, | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
// public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
//
// BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
// groupBuilder.addConstructorArgValue(createConfiguration(element));
// groupBuilder.setDestroyMethodName("close");
//
// return groupBuilder.getBeanDefinition();
// }
//
// private SpringZookeeperConfiguration createConfiguration(final Element element) {
// SpringZookeeperConfiguration result = new SpringZookeeperConfiguration(
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.NAMESPACE_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.PROJECT_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.VERSION_ATTRIBUTE),
// element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_ATTRIBUTE));
// result.setRefresh(element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.CONFIG_REFRESH));
// return result;
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
// public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
//
// @Override
// protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
// BeanDefinitionBuilder factory = BeanDefinitionBuilder
// .rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
// BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
// .rootBeanDefinition(RegistryPropertySources.class);
// definitionBuilder.addConstructorArgReference(element
// .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
// factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition());
// factory.addPropertyValue("order", "-1");
// return factory.getBeanDefinition();
// }
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/handler/RegNamespaceHandler.java
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
import com.github.config.spring.namespace.parser.ConfigGroupBeanDefinitionParser;
import com.github.config.spring.namespace.parser.PlaceholderBeanDefinitionParser;
package com.github.config.spring.namespace.handler;
/**
* 注册中心的命名空间处理器.
*
* @author ZhangWei
*/
public class RegNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_CONFIG_ELEMENT,
new ConfigGroupBeanDefinitionParser());
registerBeanDefinitionParser(ZookeeperConfigBeanDefinitionParserTag.REGISTER_PLACEHOLDER_ELEMENT, | new PlaceholderBeanDefinitionParser()); |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/AuthService.java | // Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IAuthDao.java
// public interface IAuthDao {
//
// /**
// * 检查授权
// *
// * @param nodeName
// * @param password
// * @return true: 授权成功; false: 节点已被授权
// */
// boolean checkAuth(String nodeName, String password);
//
// /**
// * 授权
// *
// * @param nodeName
// * @param password
// * @return true: 授权成功; false: 节点已被授权
// */
// boolean auth(String nodeName, String password);
//
// }
| import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.zkdao.IAuthDao; | package com.github.config.service;
/**
*
*/
@Service
public class AuthService implements IAuthService, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired | // Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/IAuthDao.java
// public interface IAuthDao {
//
// /**
// * 检查授权
// *
// * @param nodeName
// * @param password
// * @return true: 授权成功; false: 节点已被授权
// */
// boolean checkAuth(String nodeName, String password);
//
// /**
// * 授权
// *
// * @param nodeName
// * @param password
// * @return true: 授权成功; false: 节点已被授权
// */
// boolean auth(String nodeName, String password);
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/AuthService.java
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.zkdao.IAuthDao;
package com.github.config.service;
/**
*
*/
@Service
public class AuthService implements IAuthService, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired | private IAuthDao authDao; |
ErinDavid/elastic-config | elastic-config-example/src/main/java/com/github/config/demo/spring/ElasticConfigPlaceHodlerSupport.java | // Path: elastic-config-example/src/main/java/com/github/config/demo/simple/EalsticConfigBean.java
// @Setter
// @Getter
// public class EalsticConfigBean {
//
// private String stringProperty;
//
// private int intProperty;
//
// private Boolean booleanProperty;
//
// @Override
// public String toString() {
// return "EalsticCofnig [stringProperty=" + stringProperty + ", intProperty=" + intProperty
// + ", booleanProperty=" + booleanProperty + "]";
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
// @Component
// public class WithEalsticConfigBean {
//
// @Resource(name = "elasticconfig0")
// private ElasticConfig elasticConfig;
//
// public void someMethod() {
// System.out.println(elasticConfig);
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithSpelBean.java
// @Component
// public class WithSpelBean {
//
// @Value("${string_property_key}")
// private String stringProperty;
//
// @Value("${int_property_key:100}")
// private int intProperty;
//
// @Value("${boolean_property_key}")
// private boolean booleanProperty;
//
// public void someMethod() {
// System.out.println(String.format("My properties: [%s] - [%s] - [%s]", stringProperty, intProperty,
// booleanProperty));
// }
//
// }
| import lombok.Cleanup;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.github.config.demo.simple.EalsticConfigBean;
import com.github.config.demo.simple.WithEalsticConfigBean;
import com.github.config.demo.simple.WithSpelBean; | package com.github.config.demo.spring;
public class ElasticConfigPlaceHodlerSupport {
public static void main(String[] args) {
@Cleanup
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:elastic-config-placeholder.xml");
context.registerShutdownHook();
context.start();
try {
while (true) {
| // Path: elastic-config-example/src/main/java/com/github/config/demo/simple/EalsticConfigBean.java
// @Setter
// @Getter
// public class EalsticConfigBean {
//
// private String stringProperty;
//
// private int intProperty;
//
// private Boolean booleanProperty;
//
// @Override
// public String toString() {
// return "EalsticCofnig [stringProperty=" + stringProperty + ", intProperty=" + intProperty
// + ", booleanProperty=" + booleanProperty + "]";
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
// @Component
// public class WithEalsticConfigBean {
//
// @Resource(name = "elasticconfig0")
// private ElasticConfig elasticConfig;
//
// public void someMethod() {
// System.out.println(elasticConfig);
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithSpelBean.java
// @Component
// public class WithSpelBean {
//
// @Value("${string_property_key}")
// private String stringProperty;
//
// @Value("${int_property_key:100}")
// private int intProperty;
//
// @Value("${boolean_property_key}")
// private boolean booleanProperty;
//
// public void someMethod() {
// System.out.println(String.format("My properties: [%s] - [%s] - [%s]", stringProperty, intProperty,
// booleanProperty));
// }
//
// }
// Path: elastic-config-example/src/main/java/com/github/config/demo/spring/ElasticConfigPlaceHodlerSupport.java
import lombok.Cleanup;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.github.config.demo.simple.EalsticConfigBean;
import com.github.config.demo.simple.WithEalsticConfigBean;
import com.github.config.demo.simple.WithSpelBean;
package com.github.config.demo.spring;
public class ElasticConfigPlaceHodlerSupport {
public static void main(String[] args) {
@Cleanup
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:elastic-config-placeholder.xml");
context.registerShutdownHook();
context.start();
try {
while (true) {
| EalsticConfigBean exampleBean = context.getBean(EalsticConfigBean.class); |
ErinDavid/elastic-config | elastic-config-example/src/main/java/com/github/config/demo/spring/ElasticConfigPlaceHodlerSupport.java | // Path: elastic-config-example/src/main/java/com/github/config/demo/simple/EalsticConfigBean.java
// @Setter
// @Getter
// public class EalsticConfigBean {
//
// private String stringProperty;
//
// private int intProperty;
//
// private Boolean booleanProperty;
//
// @Override
// public String toString() {
// return "EalsticCofnig [stringProperty=" + stringProperty + ", intProperty=" + intProperty
// + ", booleanProperty=" + booleanProperty + "]";
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
// @Component
// public class WithEalsticConfigBean {
//
// @Resource(name = "elasticconfig0")
// private ElasticConfig elasticConfig;
//
// public void someMethod() {
// System.out.println(elasticConfig);
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithSpelBean.java
// @Component
// public class WithSpelBean {
//
// @Value("${string_property_key}")
// private String stringProperty;
//
// @Value("${int_property_key:100}")
// private int intProperty;
//
// @Value("${boolean_property_key}")
// private boolean booleanProperty;
//
// public void someMethod() {
// System.out.println(String.format("My properties: [%s] - [%s] - [%s]", stringProperty, intProperty,
// booleanProperty));
// }
//
// }
| import lombok.Cleanup;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.github.config.demo.simple.EalsticConfigBean;
import com.github.config.demo.simple.WithEalsticConfigBean;
import com.github.config.demo.simple.WithSpelBean; | package com.github.config.demo.spring;
public class ElasticConfigPlaceHodlerSupport {
public static void main(String[] args) {
@Cleanup
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:elastic-config-placeholder.xml");
context.registerShutdownHook();
context.start();
try {
while (true) {
EalsticConfigBean exampleBean = context.getBean(EalsticConfigBean.class);
System.out.println(exampleBean);
| // Path: elastic-config-example/src/main/java/com/github/config/demo/simple/EalsticConfigBean.java
// @Setter
// @Getter
// public class EalsticConfigBean {
//
// private String stringProperty;
//
// private int intProperty;
//
// private Boolean booleanProperty;
//
// @Override
// public String toString() {
// return "EalsticCofnig [stringProperty=" + stringProperty + ", intProperty=" + intProperty
// + ", booleanProperty=" + booleanProperty + "]";
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
// @Component
// public class WithEalsticConfigBean {
//
// @Resource(name = "elasticconfig0")
// private ElasticConfig elasticConfig;
//
// public void someMethod() {
// System.out.println(elasticConfig);
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithSpelBean.java
// @Component
// public class WithSpelBean {
//
// @Value("${string_property_key}")
// private String stringProperty;
//
// @Value("${int_property_key:100}")
// private int intProperty;
//
// @Value("${boolean_property_key}")
// private boolean booleanProperty;
//
// public void someMethod() {
// System.out.println(String.format("My properties: [%s] - [%s] - [%s]", stringProperty, intProperty,
// booleanProperty));
// }
//
// }
// Path: elastic-config-example/src/main/java/com/github/config/demo/spring/ElasticConfigPlaceHodlerSupport.java
import lombok.Cleanup;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.github.config.demo.simple.EalsticConfigBean;
import com.github.config.demo.simple.WithEalsticConfigBean;
import com.github.config.demo.simple.WithSpelBean;
package com.github.config.demo.spring;
public class ElasticConfigPlaceHodlerSupport {
public static void main(String[] args) {
@Cleanup
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:elastic-config-placeholder.xml");
context.registerShutdownHook();
context.start();
try {
while (true) {
EalsticConfigBean exampleBean = context.getBean(EalsticConfigBean.class);
System.out.println(exampleBean);
| WithEalsticConfigBean node = context.getBean(WithEalsticConfigBean.class); |
ErinDavid/elastic-config | elastic-config-example/src/main/java/com/github/config/demo/spring/ElasticConfigPlaceHodlerSupport.java | // Path: elastic-config-example/src/main/java/com/github/config/demo/simple/EalsticConfigBean.java
// @Setter
// @Getter
// public class EalsticConfigBean {
//
// private String stringProperty;
//
// private int intProperty;
//
// private Boolean booleanProperty;
//
// @Override
// public String toString() {
// return "EalsticCofnig [stringProperty=" + stringProperty + ", intProperty=" + intProperty
// + ", booleanProperty=" + booleanProperty + "]";
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
// @Component
// public class WithEalsticConfigBean {
//
// @Resource(name = "elasticconfig0")
// private ElasticConfig elasticConfig;
//
// public void someMethod() {
// System.out.println(elasticConfig);
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithSpelBean.java
// @Component
// public class WithSpelBean {
//
// @Value("${string_property_key}")
// private String stringProperty;
//
// @Value("${int_property_key:100}")
// private int intProperty;
//
// @Value("${boolean_property_key}")
// private boolean booleanProperty;
//
// public void someMethod() {
// System.out.println(String.format("My properties: [%s] - [%s] - [%s]", stringProperty, intProperty,
// booleanProperty));
// }
//
// }
| import lombok.Cleanup;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.github.config.demo.simple.EalsticConfigBean;
import com.github.config.demo.simple.WithEalsticConfigBean;
import com.github.config.demo.simple.WithSpelBean; | package com.github.config.demo.spring;
public class ElasticConfigPlaceHodlerSupport {
public static void main(String[] args) {
@Cleanup
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:elastic-config-placeholder.xml");
context.registerShutdownHook();
context.start();
try {
while (true) {
EalsticConfigBean exampleBean = context.getBean(EalsticConfigBean.class);
System.out.println(exampleBean);
WithEalsticConfigBean node = context.getBean(WithEalsticConfigBean.class);
node.someMethod();
| // Path: elastic-config-example/src/main/java/com/github/config/demo/simple/EalsticConfigBean.java
// @Setter
// @Getter
// public class EalsticConfigBean {
//
// private String stringProperty;
//
// private int intProperty;
//
// private Boolean booleanProperty;
//
// @Override
// public String toString() {
// return "EalsticCofnig [stringProperty=" + stringProperty + ", intProperty=" + intProperty
// + ", booleanProperty=" + booleanProperty + "]";
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
// @Component
// public class WithEalsticConfigBean {
//
// @Resource(name = "elasticconfig0")
// private ElasticConfig elasticConfig;
//
// public void someMethod() {
// System.out.println(elasticConfig);
// }
//
// }
//
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithSpelBean.java
// @Component
// public class WithSpelBean {
//
// @Value("${string_property_key}")
// private String stringProperty;
//
// @Value("${int_property_key:100}")
// private int intProperty;
//
// @Value("${boolean_property_key}")
// private boolean booleanProperty;
//
// public void someMethod() {
// System.out.println(String.format("My properties: [%s] - [%s] - [%s]", stringProperty, intProperty,
// booleanProperty));
// }
//
// }
// Path: elastic-config-example/src/main/java/com/github/config/demo/spring/ElasticConfigPlaceHodlerSupport.java
import lombok.Cleanup;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.github.config.demo.simple.EalsticConfigBean;
import com.github.config.demo.simple.WithEalsticConfigBean;
import com.github.config.demo.simple.WithSpelBean;
package com.github.config.demo.spring;
public class ElasticConfigPlaceHodlerSupport {
public static void main(String[] args) {
@Cleanup
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:elastic-config-placeholder.xml");
context.registerShutdownHook();
context.start();
try {
while (true) {
EalsticConfigBean exampleBean = context.getBean(EalsticConfigBean.class);
System.out.println(exampleBean);
WithEalsticConfigBean node = context.getBean(WithEalsticConfigBean.class);
node.someMethod();
| WithSpelBean spel = context.getBean(WithSpelBean.class); |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySource.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
| import java.util.UUID;
import org.springframework.core.env.PropertySource;
import com.github.config.api.ElasticConfig;
import com.github.config.exception.ElasticConfigException; | package com.github.config.spring.datasource;
/**
* 将注册中心的配置数据转化为属性源.
*
* @author ZhangWei
*/
public class RegistryPropertySource extends PropertySource<ElasticConfig> {
private final ElasticConfig source;
public RegistryPropertySource(final ElasticConfig source) {
super(UUID.randomUUID().toString(), source);
this.source = source;
}
@Override
public Object getProperty(final String name) {
try {
return source.getValue(name);
} | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySource.java
import java.util.UUID;
import org.springframework.core.env.PropertySource;
import com.github.config.api.ElasticConfig;
import com.github.config.exception.ElasticConfigException;
package com.github.config.spring.datasource;
/**
* 将注册中心的配置数据转化为属性源.
*
* @author ZhangWei
*/
public class RegistryPropertySource extends PropertySource<ElasticConfig> {
private final ElasticConfig source;
public RegistryPropertySource(final ElasticConfig source) {
super(UUID.randomUUID().toString(), source);
this.source = source;
}
@Override
public Object getProperty(final String name) {
try {
return source.getValue(name);
} | catch (final ElasticConfigException ex) { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyExportManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
@ManagedBean(name = "propertyExportMB")
@RequestScoped
public class PropertyExportManagedBean {
@ManagedProperty(value = "#{nodeService}") | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyExportManagedBean.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
@ManagedBean(name = "propertyExportMB")
@RequestScoped
public class PropertyExportManagedBean {
@ManagedProperty(value = "#{nodeService}") | private INodeService nodeService; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyExportManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
@ManagedBean(name = "propertyExportMB")
@RequestScoped
public class PropertyExportManagedBean {
@ManagedProperty(value = "#{nodeService}")
private INodeService nodeService;
public void setNodeService(INodeService nodeService) {
this.nodeService = nodeService;
}
@ManagedProperty(value = "#{nodeBusiness}") | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyExportManagedBean.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
@ManagedBean(name = "propertyExportMB")
@RequestScoped
public class PropertyExportManagedBean {
@ManagedProperty(value = "#{nodeService}")
private INodeService nodeService;
public void setNodeService(INodeService nodeService) {
this.nodeService = nodeService;
}
@ManagedProperty(value = "#{nodeBusiness}") | private INodeBusiness nodeBusiness; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyExportManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
@ManagedBean(name = "propertyExportMB")
@RequestScoped
public class PropertyExportManagedBean {
@ManagedProperty(value = "#{nodeService}")
private INodeService nodeService;
public void setNodeService(INodeService nodeService) {
this.nodeService = nodeService;
}
@ManagedProperty(value = "#{nodeBusiness}")
private INodeBusiness nodeBusiness;
public void setNodeBusiness(INodeBusiness nodeBusiness) {
this.nodeBusiness = nodeBusiness;
}
@ManagedProperty(value = "#{nodeAuthMB}")
private NodeAuthManagedBean nodeAuth;
public void setNodeAuth(NodeAuthManagedBean nodeAuth) {
this.nodeAuth = nodeAuth;
}
@ManagedProperty(value = "#{versionMB}")
private VersionManagedBean versionMB;
public void setVersionMB(VersionManagedBean versionMB) {
this.versionMB = versionMB;
}
private static final Logger LOGGER = LoggerFactory.getLogger(PropertyExportManagedBean.class);
/**
* 下载单个配置组,格式为properties文件
*
* @param groupName
* @return 配置组流对象
*/
public StreamedContent generateFile(String groupName) {
LOGGER.info("Export config group: {}", groupName);
StreamedContent file = null;
if (!Strings.isNullOrEmpty(groupName)) { | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/PropertyExportManagedBean.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import org.apache.commons.io.IOUtils;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
@ManagedBean(name = "propertyExportMB")
@RequestScoped
public class PropertyExportManagedBean {
@ManagedProperty(value = "#{nodeService}")
private INodeService nodeService;
public void setNodeService(INodeService nodeService) {
this.nodeService = nodeService;
}
@ManagedProperty(value = "#{nodeBusiness}")
private INodeBusiness nodeBusiness;
public void setNodeBusiness(INodeBusiness nodeBusiness) {
this.nodeBusiness = nodeBusiness;
}
@ManagedProperty(value = "#{nodeAuthMB}")
private NodeAuthManagedBean nodeAuth;
public void setNodeAuth(NodeAuthManagedBean nodeAuth) {
this.nodeAuth = nodeAuth;
}
@ManagedProperty(value = "#{versionMB}")
private VersionManagedBean versionMB;
public void setVersionMB(VersionManagedBean versionMB) {
this.versionMB = versionMB;
}
private static final Logger LOGGER = LoggerFactory.getLogger(PropertyExportManagedBean.class);
/**
* 下载单个配置组,格式为properties文件
*
* @param groupName
* @return 配置组流对象
*/
public StreamedContent generateFile(String groupName) {
LOGGER.info("Export config group: {}", groupName);
StreamedContent file = null;
if (!Strings.isNullOrEmpty(groupName)) { | List<PropertyItemVO> items = nodeBusiness.findPropertyItems(nodeAuth.getAuthedNode(), |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/zkdao/NodeDao.java | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
| import java.util.List;
import org.apache.curator.framework.api.GetChildrenBuilder;
import org.apache.curator.framework.api.GetDataBuilder;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists; | package com.github.config.service.zkdao;
/**
*
*/
public class NodeDao extends BaseDao implements INodeDao {
private static final long serialVersionUID = 6744538797251780631L;
private static final Logger LOGGER = LoggerFactory.getLogger(NodeDao.class);
@Override | // Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/zkdao/NodeDao.java
import java.util.List;
import org.apache.curator.framework.api.GetChildrenBuilder;
import org.apache.curator.framework.api.GetDataBuilder;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
package com.github.config.service.zkdao;
/**
*
*/
public class NodeDao extends BaseDao implements INodeDao {
private static final long serialVersionUID = 6744538797251780631L;
private static final Logger LOGGER = LoggerFactory.getLogger(NodeDao.class);
@Override | public List<PropertyItem> findProperties(String node) { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings; | package com.github.config.service.web.mb;
@ManagedBean(name = "nodeDataMB")
@ViewScoped | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
package com.github.config.service.web.mb;
@ManagedBean(name = "nodeDataMB")
@ViewScoped | public class NodeDataManagedBean implements Serializable, IObserver { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings; | package com.github.config.service.web.mb;
@ManagedBean(name = "nodeDataMB")
@ViewScoped
public class NodeDataManagedBean implements Serializable, IObserver {
private static final long serialVersionUID = 492472305620127433L;
@ManagedProperty(value = "#{nodeService}") | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
package com.github.config.service.web.mb;
@ManagedBean(name = "nodeDataMB")
@ViewScoped
public class NodeDataManagedBean implements Serializable, IObserver {
private static final long serialVersionUID = 492472305620127433L;
@ManagedProperty(value = "#{nodeService}") | private INodeService nodeService; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings; | package com.github.config.service.web.mb;
@ManagedBean(name = "nodeDataMB")
@ViewScoped
public class NodeDataManagedBean implements Serializable, IObserver {
private static final long serialVersionUID = 492472305620127433L;
@ManagedProperty(value = "#{nodeService}")
private INodeService nodeService;
public void setNodeService(INodeService nodeService) {
this.nodeService = nodeService;
}
@ManagedProperty(value = "#{nodeBusiness}") | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
package com.github.config.service.web.mb;
@ManagedBean(name = "nodeDataMB")
@ViewScoped
public class NodeDataManagedBean implements Serializable, IObserver {
private static final long serialVersionUID = 492472305620127433L;
@ManagedProperty(value = "#{nodeService}")
private INodeService nodeService;
public void setNodeService(INodeService nodeService) {
this.nodeService = nodeService;
}
@ManagedProperty(value = "#{nodeBusiness}") | private INodeBusiness nodeBusiness; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings; | private String getSelectedNodeCommentPath() {
if (Strings.isNullOrEmpty(selectedNode))
return null;
String authedNode = ZKPaths.makePath(nodeAuth.getAuthedNode(), versionMB.getSelectedVersion() + "$");
return ZKPaths.makePath(authedNode, selectedNode);
}
/**
* 获取属性全路径
*
* @param propertyName
* @return property node path
*/
private String getPropertyNodePath(String propertyName) {
return ZKPaths.makePath(getSelectedNodePath(), propertyName);
}
/**
* 获取属性注释全路径
*
* @param propertyName
* @return property comment path
*/
private String getPropertyCommentPath(String propertyName) {
return ZKPaths.makePath(getSelectedNodeCommentPath(), propertyName);
}
/**
* 节点下的属性列表
*/ | // Path: elastic-config-console/src/main/java/com/github/config/business/INodeBusiness.java
// public interface INodeBusiness {
//
// /**
// * 查询配置项
// *
// * @param rootNode 根结点
// * @param version 版本
// * @param group 组
// * @return
// */
// List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeDataManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.business.INodeBusiness;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
private String getSelectedNodeCommentPath() {
if (Strings.isNullOrEmpty(selectedNode))
return null;
String authedNode = ZKPaths.makePath(nodeAuth.getAuthedNode(), versionMB.getSelectedVersion() + "$");
return ZKPaths.makePath(authedNode, selectedNode);
}
/**
* 获取属性全路径
*
* @param propertyName
* @return property node path
*/
private String getPropertyNodePath(String propertyName) {
return ZKPaths.makePath(getSelectedNodePath(), propertyName);
}
/**
* 获取属性注释全路径
*
* @param propertyName
* @return property comment path
*/
private String getPropertyCommentPath(String propertyName) {
return ZKPaths.makePath(getSelectedNodeCommentPath(), propertyName);
}
/**
* 节点下的属性列表
*/ | private List<PropertyItemVO> nodeProps; |
ErinDavid/elastic-config | elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
| import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.github.config.api.ElasticConfig; | package com.github.config.demo.simple;
@Component
public class WithEalsticConfigBean {
@Resource(name = "elasticconfig0") | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
// Path: elastic-config-example/src/main/java/com/github/config/demo/simple/WithEalsticConfigBean.java
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.github.config.api.ElasticConfig;
package com.github.config.demo.simple;
@Component
public class WithEalsticConfigBean {
@Resource(name = "elasticconfig0") | private ElasticConfig elasticConfig; |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/register/zookeeper/ZookeeperConfiguration.java | // Path: elastic-config-core/src/main/java/com/github/config/register/AbstractRegistryCenterConfiguration.java
// @Getter
// @Setter
// public abstract class AbstractRegistryCenterConfiguration {
//
// /**
// * 本地属性文件路径.
// */
// private String localPropertiesPath;
//
// /**
// * 是否允许本地值覆盖注册中心.
// */
// private boolean overwrite;
// }
| import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import com.github.config.register.AbstractRegistryCenterConfiguration;
import com.google.common.base.Strings; | package com.github.config.register.zookeeper;
/**
* 基于Zookeeper的注册中心配置.
*
* @author ZhangWei
*/
@Getter
@Setter
@NoArgsConstructor | // Path: elastic-config-core/src/main/java/com/github/config/register/AbstractRegistryCenterConfiguration.java
// @Getter
// @Setter
// public abstract class AbstractRegistryCenterConfiguration {
//
// /**
// * 本地属性文件路径.
// */
// private String localPropertiesPath;
//
// /**
// * 是否允许本地值覆盖注册中心.
// */
// private boolean overwrite;
// }
// Path: elastic-config-core/src/main/java/com/github/config/register/zookeeper/ZookeeperConfiguration.java
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import com.github.config.register.AbstractRegistryCenterConfiguration;
import com.google.common.base.Strings;
package com.github.config.register.zookeeper;
/**
* 基于Zookeeper的注册中心配置.
*
* @author ZhangWei
*/
@Getter
@Setter
@NoArgsConstructor | public class ZookeeperConfiguration extends AbstractRegistryCenterConfiguration { |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/storage/ConfigNodeStorage.java | // Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/register/base/ElasticConfigRegistryCenter.java
// public interface ElasticConfigRegistryCenter extends RegistryCenter {
//
// /**
// * 直接从注册中心而非本地缓存获取数据.
// *
// * @param key 键
// * @return 值
// */
// String getDirectly(String key);
//
// /**
// * 获取子节点名称集合.
// *
// * @param key 键
// * @return 子节点名称集合
// */
// List<String> getChildrenKeys(String key);
//
// /**
// * 持久化临时注册数据.
// *
// * @param key 键
// * @param value 值
// */
// void persistEphemeral(String key, String value);
//
// /**
// * 持久化顺序注册数据.
// *
// * @param key 键
// * @return 包含10位顺序数字的znode名称
// */
// String persistSequential(String key);
//
// /**
// * 持久化临时顺序注册数据.
// *
// * @param key 键
// */
// void persistEphemeralSequential(String key);
//
// /**
// * 添加本地缓存.
// *
// * @param cachePath 需加入缓存的路径
// */
// void addCacheData(String cachePath);
//
// /**
// * 获取注册中心数据缓存对象.
// *
// * @param cachePath 缓存的节点路径
// * @return 注册中心数据缓存对象
// */
// Object getRawCache(String cachePath);
// }
| import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.apache.curator.framework.state.ConnectionStateListener;
import com.github.config.exception.ElasticConfigException;
import com.github.config.group.ZookeeperConfigProfile;
import com.github.config.register.base.ElasticConfigRegistryCenter; | package com.github.config.storage;
/**
* 配置节点数据访问类.
* <p>
* 配置节点是在普通的节点前加上配置名称的前缀.
* </p>
*
* @author ZhangWei
*/
@RequiredArgsConstructor
public class ConfigNodeStorage {
@Getter | // Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/register/base/ElasticConfigRegistryCenter.java
// public interface ElasticConfigRegistryCenter extends RegistryCenter {
//
// /**
// * 直接从注册中心而非本地缓存获取数据.
// *
// * @param key 键
// * @return 值
// */
// String getDirectly(String key);
//
// /**
// * 获取子节点名称集合.
// *
// * @param key 键
// * @return 子节点名称集合
// */
// List<String> getChildrenKeys(String key);
//
// /**
// * 持久化临时注册数据.
// *
// * @param key 键
// * @param value 值
// */
// void persistEphemeral(String key, String value);
//
// /**
// * 持久化顺序注册数据.
// *
// * @param key 键
// * @return 包含10位顺序数字的znode名称
// */
// String persistSequential(String key);
//
// /**
// * 持久化临时顺序注册数据.
// *
// * @param key 键
// */
// void persistEphemeralSequential(String key);
//
// /**
// * 添加本地缓存.
// *
// * @param cachePath 需加入缓存的路径
// */
// void addCacheData(String cachePath);
//
// /**
// * 获取注册中心数据缓存对象.
// *
// * @param cachePath 缓存的节点路径
// * @return 注册中心数据缓存对象
// */
// Object getRawCache(String cachePath);
// }
// Path: elastic-config-core/src/main/java/com/github/config/storage/ConfigNodeStorage.java
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.apache.curator.framework.state.ConnectionStateListener;
import com.github.config.exception.ElasticConfigException;
import com.github.config.group.ZookeeperConfigProfile;
import com.github.config.register.base.ElasticConfigRegistryCenter;
package com.github.config.storage;
/**
* 配置节点数据访问类.
* <p>
* 配置节点是在普通的节点前加上配置名称的前缀.
* </p>
*
* @author ZhangWei
*/
@RequiredArgsConstructor
public class ConfigNodeStorage {
@Getter | private final ElasticConfigRegistryCenter elasticConfigRegistryCenter; |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/storage/ConfigNodeStorage.java | // Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/register/base/ElasticConfigRegistryCenter.java
// public interface ElasticConfigRegistryCenter extends RegistryCenter {
//
// /**
// * 直接从注册中心而非本地缓存获取数据.
// *
// * @param key 键
// * @return 值
// */
// String getDirectly(String key);
//
// /**
// * 获取子节点名称集合.
// *
// * @param key 键
// * @return 子节点名称集合
// */
// List<String> getChildrenKeys(String key);
//
// /**
// * 持久化临时注册数据.
// *
// * @param key 键
// * @param value 值
// */
// void persistEphemeral(String key, String value);
//
// /**
// * 持久化顺序注册数据.
// *
// * @param key 键
// * @return 包含10位顺序数字的znode名称
// */
// String persistSequential(String key);
//
// /**
// * 持久化临时顺序注册数据.
// *
// * @param key 键
// */
// void persistEphemeralSequential(String key);
//
// /**
// * 添加本地缓存.
// *
// * @param cachePath 需加入缓存的路径
// */
// void addCacheData(String cachePath);
//
// /**
// * 获取注册中心数据缓存对象.
// *
// * @param cachePath 缓存的节点路径
// * @return 注册中心数据缓存对象
// */
// Object getRawCache(String cachePath);
// }
| import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.apache.curator.framework.state.ConnectionStateListener;
import com.github.config.exception.ElasticConfigException;
import com.github.config.group.ZookeeperConfigProfile;
import com.github.config.register.base.ElasticConfigRegistryCenter; | package com.github.config.storage;
/**
* 配置节点数据访问类.
* <p>
* 配置节点是在普通的节点前加上配置名称的前缀.
* </p>
*
* @author ZhangWei
*/
@RequiredArgsConstructor
public class ConfigNodeStorage {
@Getter
private final ElasticConfigRegistryCenter elasticConfigRegistryCenter;
@Getter | // Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/register/base/ElasticConfigRegistryCenter.java
// public interface ElasticConfigRegistryCenter extends RegistryCenter {
//
// /**
// * 直接从注册中心而非本地缓存获取数据.
// *
// * @param key 键
// * @return 值
// */
// String getDirectly(String key);
//
// /**
// * 获取子节点名称集合.
// *
// * @param key 键
// * @return 子节点名称集合
// */
// List<String> getChildrenKeys(String key);
//
// /**
// * 持久化临时注册数据.
// *
// * @param key 键
// * @param value 值
// */
// void persistEphemeral(String key, String value);
//
// /**
// * 持久化顺序注册数据.
// *
// * @param key 键
// * @return 包含10位顺序数字的znode名称
// */
// String persistSequential(String key);
//
// /**
// * 持久化临时顺序注册数据.
// *
// * @param key 键
// */
// void persistEphemeralSequential(String key);
//
// /**
// * 添加本地缓存.
// *
// * @param cachePath 需加入缓存的路径
// */
// void addCacheData(String cachePath);
//
// /**
// * 获取注册中心数据缓存对象.
// *
// * @param cachePath 缓存的节点路径
// * @return 注册中心数据缓存对象
// */
// Object getRawCache(String cachePath);
// }
// Path: elastic-config-core/src/main/java/com/github/config/storage/ConfigNodeStorage.java
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.apache.curator.framework.state.ConnectionStateListener;
import com.github.config.exception.ElasticConfigException;
import com.github.config.group.ZookeeperConfigProfile;
import com.github.config.register.base.ElasticConfigRegistryCenter;
package com.github.config.storage;
/**
* 配置节点数据访问类.
* <p>
* 配置节点是在普通的节点前加上配置名称的前缀.
* </p>
*
* @author ZhangWei
*/
@RequiredArgsConstructor
public class ConfigNodeStorage {
@Getter
private final ElasticConfigRegistryCenter elasticConfigRegistryCenter;
@Getter | private final ZookeeperConfigProfile configProfile; |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/storage/ConfigNodeStorage.java | // Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/register/base/ElasticConfigRegistryCenter.java
// public interface ElasticConfigRegistryCenter extends RegistryCenter {
//
// /**
// * 直接从注册中心而非本地缓存获取数据.
// *
// * @param key 键
// * @return 值
// */
// String getDirectly(String key);
//
// /**
// * 获取子节点名称集合.
// *
// * @param key 键
// * @return 子节点名称集合
// */
// List<String> getChildrenKeys(String key);
//
// /**
// * 持久化临时注册数据.
// *
// * @param key 键
// * @param value 值
// */
// void persistEphemeral(String key, String value);
//
// /**
// * 持久化顺序注册数据.
// *
// * @param key 键
// * @return 包含10位顺序数字的znode名称
// */
// String persistSequential(String key);
//
// /**
// * 持久化临时顺序注册数据.
// *
// * @param key 键
// */
// void persistEphemeralSequential(String key);
//
// /**
// * 添加本地缓存.
// *
// * @param cachePath 需加入缓存的路径
// */
// void addCacheData(String cachePath);
//
// /**
// * 获取注册中心数据缓存对象.
// *
// * @param cachePath 缓存的节点路径
// * @return 注册中心数据缓存对象
// */
// Object getRawCache(String cachePath);
// }
| import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.apache.curator.framework.state.ConnectionStateListener;
import com.github.config.exception.ElasticConfigException;
import com.github.config.group.ZookeeperConfigProfile;
import com.github.config.register.base.ElasticConfigRegistryCenter; | value.toString());
}
/**
* 替换节点数据.
*
* @param node
* 节点名称
* @param value
* 待替换的数据
*/
public void replaceConfigNode(final String node, final Object value) {
elasticConfigRegistryCenter.persist(configProfile.getFullPath(node),
value.toString());
}
/**
* 添加本地缓存.
*
* @param cachePath
* 需加入缓存的路径
*/
public void addDataCache(final String cachePath) {
elasticConfigRegistryCenter.addCacheData(cachePath);
}
private void handleException(final Exception ex) {
if (ex instanceof InterruptedException) {
Thread.currentThread().interrupt();
} else { | // Path: elastic-config-core/src/main/java/com/github/config/exception/ElasticConfigException.java
// public class ElasticConfigException extends RuntimeException {
//
// private static final long serialVersionUID = -509739591923183173L;
//
// public ElasticConfigException(final String errorMessage, final Object... args) {
// super(String.format(errorMessage, args));
// }
//
// public ElasticConfigException(final Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/register/base/ElasticConfigRegistryCenter.java
// public interface ElasticConfigRegistryCenter extends RegistryCenter {
//
// /**
// * 直接从注册中心而非本地缓存获取数据.
// *
// * @param key 键
// * @return 值
// */
// String getDirectly(String key);
//
// /**
// * 获取子节点名称集合.
// *
// * @param key 键
// * @return 子节点名称集合
// */
// List<String> getChildrenKeys(String key);
//
// /**
// * 持久化临时注册数据.
// *
// * @param key 键
// * @param value 值
// */
// void persistEphemeral(String key, String value);
//
// /**
// * 持久化顺序注册数据.
// *
// * @param key 键
// * @return 包含10位顺序数字的znode名称
// */
// String persistSequential(String key);
//
// /**
// * 持久化临时顺序注册数据.
// *
// * @param key 键
// */
// void persistEphemeralSequential(String key);
//
// /**
// * 添加本地缓存.
// *
// * @param cachePath 需加入缓存的路径
// */
// void addCacheData(String cachePath);
//
// /**
// * 获取注册中心数据缓存对象.
// *
// * @param cachePath 缓存的节点路径
// * @return 注册中心数据缓存对象
// */
// Object getRawCache(String cachePath);
// }
// Path: elastic-config-core/src/main/java/com/github/config/storage/ConfigNodeStorage.java
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.apache.curator.framework.state.ConnectionStateListener;
import com.github.config.exception.ElasticConfigException;
import com.github.config.group.ZookeeperConfigProfile;
import com.github.config.register.base.ElasticConfigRegistryCenter;
value.toString());
}
/**
* 替换节点数据.
*
* @param node
* 节点名称
* @param value
* 待替换的数据
*/
public void replaceConfigNode(final String node, final Object value) {
elasticConfigRegistryCenter.persist(configProfile.getFullPath(node),
value.toString());
}
/**
* 添加本地缓存.
*
* @param cachePath
* 需加入缓存的路径
*/
public void addDataCache(final String cachePath) {
elasticConfigRegistryCenter.addCacheData(cachePath);
}
private void handleException(final Exception ex) {
if (ex instanceof InterruptedException) {
Thread.currentThread().interrupt();
} else { | throw new ElasticConfigException(ex); |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/VersionManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
/**
* 属性版本请求处理
*/
@ManagedBean(name = "versionMB")
@SessionScoped | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/VersionManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
/**
* 属性版本请求处理
*/
@ManagedBean(name = "versionMB")
@SessionScoped | public class VersionManagedBean implements IObserver, Serializable { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/VersionManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
/**
* 属性版本请求处理
*/
@ManagedBean(name = "versionMB")
@SessionScoped
public class VersionManagedBean implements IObserver, Serializable {
private static final long serialVersionUID = 1L;
@ManagedProperty(value = "#{nodeService}") | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/VersionManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
/**
* 属性版本请求处理
*/
@ManagedBean(name = "versionMB")
@SessionScoped
public class VersionManagedBean implements IObserver, Serializable {
private static final long serialVersionUID = 1L;
@ManagedProperty(value = "#{nodeService}") | private INodeService nodeService; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/VersionManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; | /**
* 克隆版本
*/
public void cloneVersion() {
String versionToClone = (String) versionToCloneInput.getValue();
if (!Strings.isNullOrEmpty(versionToClone) && !Strings.isNullOrEmpty(selectedVersion)) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Clone version [{}] from version [{}].", versionToClone, selectedVersion);
}
cloneTree(ZKPaths.makePath(nodeAuth.getAuthedNode(), selectedVersion),
ZKPaths.makePath(nodeAuth.getAuthedNode(), versionToClone));
cloneTree(ZKPaths.makePath(nodeAuth.getAuthedNode(), selectedVersion + "$"),
ZKPaths.makePath(nodeAuth.getAuthedNode(), versionToClone + "$"));
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Version cloned.", versionToClone));
refresh();
selectedVersion = versionToClone;
versionToCloneInput.setValue("");
}
}
private void cloneTree(String sourceVersionPath, String destinationVersionPath) {
List<String> sourceGroups = nodeService.listChildren(sourceVersionPath);
if (sourceGroups != null) {
for (String sourceGroup : sourceGroups) {
String sourceGroupFullPath = ZKPaths.makePath(sourceVersionPath, sourceGroup);
String destinationGroupFullPath = ZKPaths.makePath(destinationVersionPath, sourceGroup);
nodeService.createProperty(destinationGroupFullPath, null); | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/VersionManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.curator.utils.ZKPaths;
import org.primefaces.component.inputtext.InputText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.config.observer.IObserver;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
/**
* 克隆版本
*/
public void cloneVersion() {
String versionToClone = (String) versionToCloneInput.getValue();
if (!Strings.isNullOrEmpty(versionToClone) && !Strings.isNullOrEmpty(selectedVersion)) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Clone version [{}] from version [{}].", versionToClone, selectedVersion);
}
cloneTree(ZKPaths.makePath(nodeAuth.getAuthedNode(), selectedVersion),
ZKPaths.makePath(nodeAuth.getAuthedNode(), versionToClone));
cloneTree(ZKPaths.makePath(nodeAuth.getAuthedNode(), selectedVersion + "$"),
ZKPaths.makePath(nodeAuth.getAuthedNode(), versionToClone + "$"));
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Version cloned.", versionToClone));
refresh();
selectedVersion = versionToClone;
versionToCloneInput.setValue("");
}
}
private void cloneTree(String sourceVersionPath, String destinationVersionPath) {
List<String> sourceGroups = nodeService.listChildren(sourceVersionPath);
if (sourceGroups != null) {
for (String sourceGroup : sourceGroups) {
String sourceGroupFullPath = ZKPaths.makePath(sourceVersionPath, sourceGroup);
String destinationGroupFullPath = ZKPaths.makePath(destinationVersionPath, sourceGroup);
nodeService.createProperty(destinationGroupFullPath, null); | List<PropertyItem> sourceProperties = nodeService.findProperties(sourceGroupFullPath); |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBusFactory.java | // Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventPublisher.java
// public class EventPublisher {
//
// private final EventBus instance = new EventBus();
//
// private final ConcurrentHashMap<String, EventListener> listeners = new ConcurrentHashMap<String, EventListener>();
//
// /**
// * 事件发布件.
// *
// * @param event 发布事件
// */
// public void pushEvent(final NodeEvent event) {
// if (listeners.isEmpty()) {
// return;
// }
// instance.post(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener 事件监听器
// */
// public void register(final EventListener listener) {
// if (null != listeners.putIfAbsent(listener.getName(), listener)) {
// return;
// }
// instance.register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public synchronized void clearListener() {
// for (EventListener each : listeners.values()) {
// instance.unregister(each);
// }
// listeners.clear();
// }
// }
| import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import com.github.config.bus.event.EventPublisher; | package com.github.config.bus;
/**
* 事件总线工厂.
*
* @author ZhangWei
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ElasticConfigEventBusFactory {
| // Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventPublisher.java
// public class EventPublisher {
//
// private final EventBus instance = new EventBus();
//
// private final ConcurrentHashMap<String, EventListener> listeners = new ConcurrentHashMap<String, EventListener>();
//
// /**
// * 事件发布件.
// *
// * @param event 发布事件
// */
// public void pushEvent(final NodeEvent event) {
// if (listeners.isEmpty()) {
// return;
// }
// instance.post(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener 事件监听器
// */
// public void register(final EventListener listener) {
// if (null != listeners.putIfAbsent(listener.getName(), listener)) {
// return;
// }
// instance.register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public synchronized void clearListener() {
// for (EventListener each : listeners.values()) {
// instance.unregister(each);
// }
// listeners.clear();
// }
// }
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBusFactory.java
import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import com.github.config.bus.event.EventPublisher;
package com.github.config.bus;
/**
* 事件总线工厂.
*
* @author ZhangWei
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ElasticConfigEventBusFactory {
| private static final ConcurrentHashMap<String, EventPublisher> CONTAINER = new ConcurrentHashMap<String, EventPublisher>(); |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
| import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe; | package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
// Path: elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor | public class ElaticCofnigEventListener implements EventListener { |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
| import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe; | package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public class ElaticCofnigEventListener implements EventListener {
| // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
// Path: elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public class ElaticCofnigEventListener implements EventListener {
| private final ElasticConfig elasticConfig; |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
| import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe; | package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public class ElaticCofnigEventListener implements EventListener {
private final ElasticConfig elasticConfig;
@Subscribe
@AllowConcurrentEvents | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
// Path: elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public class ElaticCofnigEventListener implements EventListener {
private final ElasticConfig elasticConfig;
@Subscribe
@AllowConcurrentEvents | public void listen(final ElasticConfigEvent event) { |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
| import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe; | package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public class ElaticCofnigEventListener implements EventListener {
private final ElasticConfig elasticConfig;
@Subscribe
@AllowConcurrentEvents
public void listen(final ElasticConfigEvent event) {
log.info("recieve event:{}", event.toString());
elasticConfig.refresh();
}
@Override
public String getName() {
return ElaticCofnigEventListener.class.getName();
}
@Override
public void register() { | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEvent.java
// public final class ElasticConfigEvent extends NodeEvent {
//
// private ElasticConfigEvent(final String path, final String value, final EvenType eventExecutionType) {
// super(path, value, eventExecutionType);
// }
//
// public static ElasticConfigEventBuilder builder() {
// return new ElasticConfigEventBuilder();
// }
//
// @NoArgsConstructor
// public static class ElasticConfigEventBuilder {
//
// /**
// * 节点路径
// */
// private String path;
//
// /**
// * 节点值
// */
// private String value;
//
// /**
// * 事件类型
// */
// private EvenType eventType;
//
// public ElasticConfigEventBuilder path(final String path) {
//
// this.path = path;
// return this;
// }
//
// public ElasticConfigEventBuilder value(final String value) {
//
// this.value = value;
// return this;
// }
//
// public ElasticConfigEventBuilder eventType(EvenType eventType) {
//
// this.eventType = eventType;
// return this;
// }
//
// public ElasticConfigEvent build() {
// return new ElasticConfigEvent(path, value, eventType);
// }
// }
//
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public final class ElasticConfigEventBus {
//
// private static final String NAME = "Config-EventBus";
//
// /**
// * 发布事件.
// *
// * @param event ElasticConfig事件
// */
// public static void pushEvent(final ElasticConfigEvent event) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
// }
//
// /**
// * 注册事件监听器.
// *
// * @param listener ElasticConfig事件监听器
// */
// public static void register(final ElaticCofnigEventListener listener) {
//
// ElasticConfigEventBusFactory.getInstance(NAME).register(listener);
// }
//
// /**
// * 清除监听器.
// */
// public static void clearListener() {
//
// ElasticConfigEventBusFactory.getInstance(NAME).clearListener();
// }
// }
//
// Path: elastic-config-core/src/main/java/com/github/config/bus/event/EventListener.java
// public interface EventListener {
//
// /**
// * 事件监听器名称
// *
// * @return 事件监听器名称
// */
// String getName();
//
// /**
// * 监听器注册
// */
// void register();
// }
// Path: elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.config.api.ElasticConfig;
import com.github.config.bus.ElasticConfigEvent;
import com.github.config.bus.ElasticConfigEventBus;
import com.github.config.bus.event.EventListener;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
package com.github.config.listener;
/**
* ElaticCofnig事件监听器.
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public class ElaticCofnigEventListener implements EventListener {
private final ElasticConfig elasticConfig;
@Subscribe
@AllowConcurrentEvents
public void listen(final ElasticConfigEvent event) {
log.info("recieve event:{}", event.toString());
elasticConfig.refresh();
}
@Override
public String getName() {
return ElaticCofnigEventListener.class.getName();
}
@Override
public void register() { | ElasticConfigEventBus.register(this); |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/business/NodeBusiness.java | // Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.curator.utils.ZKPaths;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; | package com.github.config.business;
@Service
public class NodeBusiness implements INodeBusiness {
@Autowired | // Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/business/NodeBusiness.java
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.curator.utils.ZKPaths;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
package com.github.config.business;
@Service
public class NodeBusiness implements INodeBusiness {
@Autowired | private INodeService nodeService; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/business/NodeBusiness.java | // Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.curator.utils.ZKPaths;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; | package com.github.config.business;
@Service
public class NodeBusiness implements INodeBusiness {
@Autowired
private INodeService nodeService;
@Override | // Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/business/NodeBusiness.java
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.curator.utils.ZKPaths;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
package com.github.config.business;
@Service
public class NodeBusiness implements INodeBusiness {
@Autowired
private INodeService nodeService;
@Override | public List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group) { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/business/NodeBusiness.java | // Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
| import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.curator.utils.ZKPaths;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; | package com.github.config.business;
@Service
public class NodeBusiness implements INodeBusiness {
@Autowired
private INodeService nodeService;
@Override
public List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group) {
List<PropertyItemVO> items = null;
if (!Strings.isNullOrEmpty(rootNode) && !Strings.isNullOrEmpty(version) && !Strings.isNullOrEmpty(group)) { | // Path: elastic-config-console/src/main/java/com/github/config/service/INodeService.java
// public interface INodeService {
//
// List<PropertyItem> findProperties(String node);
//
// List<String> listChildren(String node);
//
// boolean createProperty(String nodeName, String value);
//
// boolean updateProperty(String nodeName, String value);
//
// void deleteProperty(String nodeName);
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItem.java
// public class PropertyItem implements Serializable {
//
// private static final long serialVersionUID = -3189608011329109220L;
//
// private String name;
//
// private String value;
//
// public PropertyItem(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/entity/PropertyItemVO.java
// public class PropertyItemVO implements Serializable, Comparable<PropertyItemVO> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// private String oriName;
//
// private String name;
//
// private String value;
//
// private String comment;
//
// public PropertyItemVO() {
// super();
// }
//
// public PropertyItemVO(PropertyItem propertyItem) {
// super();
// this.name = propertyItem.getName();
// this.oriName = propertyItem.getName();
// this.value = propertyItem.getValue();
// }
//
// public PropertyItemVO(String name, String value) {
// super();
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getOriName() {
// return oriName;
// }
//
// public void setOriName(String oriName) {
// this.oriName = oriName;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// @Override
// public String toString() {
// return "PropertyItemVO [oriName=" + oriName + ", name=" + name + ", value=" + value + ", comment=" + comment
// + "]";
// }
//
// /*
// * (non-Javadoc)
// * @see java.lang.Comparable#compareTo(java.lang.Object)
// */
// @Override
// public int compareTo(PropertyItemVO o) {
// return this.name.compareTo(o.getName());
// }
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/business/NodeBusiness.java
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.curator.utils.ZKPaths;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.config.service.INodeService;
import com.github.config.service.entity.PropertyItem;
import com.github.config.service.entity.PropertyItemVO;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
package com.github.config.business;
@Service
public class NodeBusiness implements INodeBusiness {
@Autowired
private INodeService nodeService;
@Override
public List<PropertyItemVO> findPropertyItems(String rootNode, String version, String group) {
List<PropertyItemVO> items = null;
if (!Strings.isNullOrEmpty(rootNode) && !Strings.isNullOrEmpty(version) && !Strings.isNullOrEmpty(group)) { | List<PropertyItem> propertyItems = nodeService.findProperties(getGroupFullPath(rootNode, version, group)); |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/datasource/factory/ElasticConfigSourceFactory.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySource.java
// public class RegistryPropertySource extends PropertySource<ElasticConfig> {
//
// private final ElasticConfig source;
//
// public RegistryPropertySource(final ElasticConfig source) {
// super(UUID.randomUUID().toString(), source);
// this.source = source;
// }
//
// @Override
// public Object getProperty(final String name) {
// try {
// return source.getValue(name);
// }
// catch (final ElasticConfigException ex) {
// return null;
// }
// }
// }
| import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySources;
import com.github.config.api.ElasticConfig;
import com.github.config.spring.datasource.RegistryPropertySource;
import com.google.common.base.Preconditions; | package com.github.config.spring.datasource.factory;
/**
* 配置来源工厂
*
* @author ZhangWei
*/
public class ElasticConfigSourceFactory {
public static PropertySources create(ElasticConfig... elasticConfigs) {
Preconditions.checkNotNull(elasticConfigs);
final MutablePropertySources sources = new MutablePropertySources();
for (ElasticConfig elasticConfig : elasticConfigs) { | // Path: elastic-config-core/src/main/java/com/github/config/api/ElasticConfig.java
// public interface ElasticConfig extends Closeable {
//
// /**
// * 根据配置组中key获取对应的值
// *
// * @param key
// * 配置组中key
// * @return key对应的值
// */
// String getValue(String key);
//
// /**
// * 添加key,value到配置组中
// *
// * @param key
// * 配置组中key
// * @param value
// * 配置组中value
// * @return 配置组中key原来的值
// */
// String putValue(String key, String value);
//
// /**
// * 删除配置组中的key
// *
// * @param key
// * 配置组中key
// * @return 配置组中key原来的值
// */
// String removeValue(String key);
//
// /**
// * 配置刷新
// */
// void refresh();
//
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySource.java
// public class RegistryPropertySource extends PropertySource<ElasticConfig> {
//
// private final ElasticConfig source;
//
// public RegistryPropertySource(final ElasticConfig source) {
// super(UUID.randomUUID().toString(), source);
// this.source = source;
// }
//
// @Override
// public Object getProperty(final String name) {
// try {
// return source.getValue(name);
// }
// catch (final ElasticConfigException ex) {
// return null;
// }
// }
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/factory/ElasticConfigSourceFactory.java
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySources;
import com.github.config.api.ElasticConfig;
import com.github.config.spring.datasource.RegistryPropertySource;
import com.google.common.base.Preconditions;
package com.github.config.spring.datasource.factory;
/**
* 配置来源工厂
*
* @author ZhangWei
*/
public class ElasticConfigSourceFactory {
public static PropertySources create(ElasticConfig... elasticConfigs) {
Preconditions.checkNotNull(elasticConfigs);
final MutablePropertySources sources = new MutablePropertySources();
for (ElasticConfig elasticConfig : elasticConfigs) { | sources.addLast(new RegistryPropertySource(elasticConfig)); |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java | // Path: elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java
// @Slf4j
// @RequiredArgsConstructor
// public class ElaticCofnigEventListener implements EventListener {
//
// private final ElasticConfig elasticConfig;
//
// @Subscribe
// @AllowConcurrentEvents
// public void listen(final ElasticConfigEvent event) {
// log.info("recieve event:{}", event.toString());
// elasticConfig.refresh();
// }
//
// @Override
// public String getName() {
// return ElaticCofnigEventListener.class.getName();
// }
//
// @Override
// public void register() {
// ElasticConfigEventBus.register(this);
//
// }
// }
| import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import com.github.config.listener.ElaticCofnigEventListener;
| package com.github.config.bus;
/**
* ElasticConfig事件总线.
*
* @author ZhangWei
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ElasticConfigEventBus {
private static final String NAME = "Config-EventBus";
/**
* 发布事件.
*
* @param event ElasticConfig事件
*/
public static void pushEvent(final ElasticConfigEvent event) {
ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
}
/**
* 注册事件监听器.
*
* @param listener ElasticConfig事件监听器
*/
| // Path: elastic-config-core/src/main/java/com/github/config/listener/ElaticCofnigEventListener.java
// @Slf4j
// @RequiredArgsConstructor
// public class ElaticCofnigEventListener implements EventListener {
//
// private final ElasticConfig elasticConfig;
//
// @Subscribe
// @AllowConcurrentEvents
// public void listen(final ElasticConfigEvent event) {
// log.info("recieve event:{}", event.toString());
// elasticConfig.refresh();
// }
//
// @Override
// public String getName() {
// return ElaticCofnigEventListener.class.getName();
// }
//
// @Override
// public void register() {
// ElasticConfigEventBus.register(this);
//
// }
// }
// Path: elastic-config-core/src/main/java/com/github/config/bus/ElasticConfigEventBus.java
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import com.github.config.listener.ElaticCofnigEventListener;
package com.github.config.bus;
/**
* ElasticConfig事件总线.
*
* @author ZhangWei
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ElasticConfigEventBus {
private static final String NAME = "Config-EventBus";
/**
* 发布事件.
*
* @param event ElasticConfig事件
*/
public static void pushEvent(final ElasticConfigEvent event) {
ElasticConfigEventBusFactory.getInstance(NAME).pushEvent(event);
}
/**
* 注册事件监听器.
*
* @param listener ElasticConfig事件监听器
*/
| public static void register(final ElaticCofnigEventListener listener) {
|
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/api/AbstractElasticConfig.java | // Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
| import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import com.github.config.group.ZookeeperConfigProfile;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
| package com.github.config.api;
/**
* ElasticConfig 抽象类
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public abstract class AbstractElasticConfig extends ConcurrentHashMap<String, String> implements ElasticConfig {
private static final long serialVersionUID = -2349529888901701071L;
@Getter
| // Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
// @Setter
// @Getter
// @ToString
// @NoArgsConstructor
// public class ZookeeperConfigProfile extends ConfigProfile {
//
// public ZookeeperConfigProfile(String serverlist, String namespaces, String rootNode, String version) {
// super(rootNode, version);
// this.serverlist = serverlist;
// this.namespaces = namespaces;
// }
//
// /**
// * zookeeper地址,包括IP地址和端口号. 多个地址用逗号分隔
// */
// private String serverlist;
//
// /**
// * Zookeeper项目配置命名空间
// */
// private String namespaces;
//
// /**
// * Zookeeper项目配置监控端口
// */
// private int monitorPort = -1;
//
// public String getConcurrentRootNodePath() {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getVersionRootNodePath(String node) {
// return ZKPaths.makePath(rootNode, version, node);
// }
//
// public String getFullPath(String key) {
// return ZKPaths.makePath(rootNode, version, node, key);
// }
//
// public boolean isVersionRootPath(String path) {
// return getConcurrentRootNodePath().equals(path);
// }
// }
// Path: elastic-config-core/src/main/java/com/github/config/api/AbstractElasticConfig.java
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import com.github.config.group.ZookeeperConfigProfile;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
package com.github.config.api;
/**
* ElasticConfig 抽象类
*
* @author ZhangWei
*/
@Slf4j
@RequiredArgsConstructor
public abstract class AbstractElasticConfig extends ConcurrentHashMap<String, String> implements ElasticConfig {
private static final long serialVersionUID = -2349529888901701071L;
@Getter
| protected final ZookeeperConfigProfile configProfile;
|
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
| import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag; | package com.github.config.spring.namespace.parser;
/**
* 注册中心配置项使用占位符的命名空间解析器.
*
* @author ZhangWei
*/
public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
.rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
groupBuilder.addConstructorArgValue(createConfiguration(element));
groupBuilder.setDestroyMethodName("close");
return groupBuilder.getBeanDefinition();
}
private SpringZookeeperConfiguration createConfiguration(final Element element) {
SpringZookeeperConfiguration result = new SpringZookeeperConfiguration( | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/ConfigGroupBeanDefinitionParser.java
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
package com.github.config.spring.namespace.parser;
/**
* 注册中心配置项使用占位符的命名空间解析器.
*
* @author ZhangWei
*/
public class ConfigGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder groupBuilder = BeanDefinitionBuilder
.rootBeanDefinition(SpringZookeeperElasticConfigGroup.class);
groupBuilder.addConstructorArgValue(createConfiguration(element));
groupBuilder.setDestroyMethodName("close");
return groupBuilder.getBeanDefinition();
}
private SpringZookeeperConfiguration createConfiguration(final Element element) {
SpringZookeeperConfiguration result = new SpringZookeeperConfiguration( | element.getAttribute(ZookeeperConfigBeanDefinitionParserTag.SERVERLIST_ATTRIBUTE), |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
/**
* 节点授权
*/
@ManagedBean(name = "nodeAuthMB")
@SessionScoped | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
/**
* 节点授权
*/
@ManagedBean(name = "nodeAuthMB")
@SessionScoped | public class NodeAuthManagedBean implements Serializable, ISubject { |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
/**
* 节点授权
*/
@ManagedBean(name = "nodeAuthMB")
@SessionScoped
public class NodeAuthManagedBean implements Serializable, ISubject {
private static final long serialVersionUID = -5359262798219710859L;
private String nodeName;
private String password;
private String authedNode;
@ManagedProperty(value = "#{authService}") | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
/**
* 节点授权
*/
@ManagedBean(name = "nodeAuthMB")
@SessionScoped
public class NodeAuthManagedBean implements Serializable, ISubject {
private static final long serialVersionUID = -5359262798219710859L;
private String nodeName;
private String password;
private String authedNode;
@ManagedProperty(value = "#{authService}") | private IAuthService authService; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; | package com.github.config.service.web.mb;
/**
* 节点授权
*/
@ManagedBean(name = "nodeAuthMB")
@SessionScoped
public class NodeAuthManagedBean implements Serializable, ISubject {
private static final long serialVersionUID = -5359262798219710859L;
private String nodeName;
private String password;
private String authedNode;
@ManagedProperty(value = "#{authService}")
private IAuthService authService;
@ManagedProperty(value = "#{rootNodeRecorder}") | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
package com.github.config.service.web.mb;
/**
* 节点授权
*/
@ManagedBean(name = "nodeAuthMB")
@SessionScoped
public class NodeAuthManagedBean implements Serializable, ISubject {
private static final long serialVersionUID = -5359262798219710859L;
private String nodeName;
private String password;
private String authedNode;
@ManagedProperty(value = "#{authService}")
private IAuthService authService;
@ManagedProperty(value = "#{rootNodeRecorder}") | private IRootNodeRecorder rootNodeRecorder; |
ErinDavid/elastic-config | elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
| import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; | this.password = password;
}
public void setAuthService(IAuthService authService) {
this.authService = authService;
}
public final void setRootNodeRecorder(IRootNodeRecorder rootNodeRecorder) {
this.rootNodeRecorder = rootNodeRecorder;
}
public String getNodeName() {
return nodeName;
}
public String getPassword() {
return password;
}
public String getAuthedNode() {
return authedNode;
}
public void setAuthedNode(String authedNode) {
this.authedNode = authedNode;
}
/**
* 观察者列表
*/ | // Path: elastic-config-console/src/main/java/com/github/config/observer/IObserver.java
// public interface IObserver {
//
// /**
// * 通知
// *
// * @param data
// */
// void notified(String data, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/observer/ISubject.java
// public interface ISubject {
//
// /**
// * 注册观察者
// *
// * @param watcher
// */
// void register(IObserver watcher);
//
// /**
// * 通知观察者
// *
// * @param key
// * @param value
// */
// void notify(String key, String value);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IAuthService.java
// public interface IAuthService {
//
// boolean checkAuth(String nodeName, String password);
//
// boolean auth(String nodeName, String password);
//
// }
//
// Path: elastic-config-console/src/main/java/com/github/config/service/IRootNodeRecorder.java
// public interface IRootNodeRecorder {
//
// void saveNode(String node);
//
// List<String> listNode();
//
// }
// Path: elastic-config-console/src/main/java/com/github/config/service/web/mb/NodeAuthManagedBean.java
import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import com.github.config.observer.IObserver;
import com.github.config.observer.ISubject;
import com.github.config.service.IAuthService;
import com.github.config.service.IRootNodeRecorder;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
this.password = password;
}
public void setAuthService(IAuthService authService) {
this.authService = authService;
}
public final void setRootNodeRecorder(IRootNodeRecorder rootNodeRecorder) {
this.rootNodeRecorder = rootNodeRecorder;
}
public String getNodeName() {
return nodeName;
}
public String getPassword() {
return password;
}
public String getAuthedNode() {
return authedNode;
}
public void setAuthedNode(String authedNode) {
this.authedNode = authedNode;
}
/**
* 观察者列表
*/ | private final List<IObserver> watchers = Lists.newArrayList(); |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySources.java
// public class RegistryPropertySources extends MutablePropertySources {
// public RegistryPropertySources(final ElasticConfig registryCenter) {
// addLast(new RegistryPropertySource(registryCenter));
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
| import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.w3c.dom.Element;
import com.github.config.spring.datasource.RegistryPropertySources;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag; | package com.github.config.spring.namespace.parser;
/**
* 注册中心占位符命名空间解析器.
*
* @author ZhangWei
*/
public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder
.rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySources.java
// public class RegistryPropertySources extends MutablePropertySources {
// public RegistryPropertySources(final ElasticConfig registryCenter) {
// addLast(new RegistryPropertySource(registryCenter));
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.w3c.dom.Element;
import com.github.config.spring.datasource.RegistryPropertySources;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
package com.github.config.spring.namespace.parser;
/**
* 注册中心占位符命名空间解析器.
*
* @author ZhangWei
*/
public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder
.rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder | .rootBeanDefinition(RegistryPropertySources.class); |
ErinDavid/elastic-config | elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySources.java
// public class RegistryPropertySources extends MutablePropertySources {
// public RegistryPropertySources(final ElasticConfig registryCenter) {
// addLast(new RegistryPropertySource(registryCenter));
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
| import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.w3c.dom.Element;
import com.github.config.spring.datasource.RegistryPropertySources;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag; | package com.github.config.spring.namespace.parser;
/**
* 注册中心占位符命名空间解析器.
*
* @author ZhangWei
*/
public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder
.rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
.rootBeanDefinition(RegistryPropertySources.class);
definitionBuilder.addConstructorArgReference(element | // Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/RegistryPropertySources.java
// public class RegistryPropertySources extends MutablePropertySources {
// public RegistryPropertySources(final ElasticConfig registryCenter) {
// addLast(new RegistryPropertySource(registryCenter));
// }
// }
//
// Path: elastic-config-spring/src/main/java/com/github/config/spring/datasource/tag/ZookeeperConfigBeanDefinitionParserTag.java
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// public class ZookeeperConfigBeanDefinitionParserTag {
//
// public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref";
//
// public static final String SERVERLIST_ATTRIBUTE = "serverlist";
//
// public static final String NAMESPACE_ATTRIBUTE = "namespace";
//
// public static final String PROJECT_ATTRIBUTE = "project";
//
// public static final String CONFIG_ATTRIBUTE = "node";
//
// public static final String VERSION_ATTRIBUTE = "version";
//
// public static final String REGISTER_CONFIG_ELEMENT = "config";
//
// public static final String CONFIG_REFRESH = "refresh";
//
// public static final String REGISTER_PLACEHOLDER_ELEMENT = "placeholder";
//
// }
// Path: elastic-config-spring/src/main/java/com/github/config/spring/namespace/parser/PlaceholderBeanDefinitionParser.java
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.w3c.dom.Element;
import com.github.config.spring.datasource.RegistryPropertySources;
import com.github.config.spring.datasource.tag.ZookeeperConfigBeanDefinitionParserTag;
package com.github.config.spring.namespace.parser;
/**
* 注册中心占位符命名空间解析器.
*
* @author ZhangWei
*/
public class PlaceholderBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder
.rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
.rootBeanDefinition(RegistryPropertySources.class);
definitionBuilder.addConstructorArgReference(element | .getAttribute(ZookeeperConfigBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE)); |
ErinDavid/elastic-config | elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java | // Path: elastic-config-core/src/main/java/com/github/config/api/ConfigProfile.java
// @Setter
// @Getter
// @NoArgsConstructor
// public abstract class ConfigProfile {
//
// public ConfigProfile(String rootNode, String version) {
// super();
// this.version = version;
// this.rootNode = rootNode;
// }
//
// /**
// * 配置结点
// */
// protected String node;
//
// /**
// * 项目根结点
// */
// protected String rootNode;
//
// /**
// * 项目配置版本
// */
// protected String version;
//
// /**
// * 本地配置文件
// */
// protected Multimap<String, File> filemultimap;
//
// /**
// * 需要包含或排除的key
// */
// private Set<String> keysSpecified = Sets.newConcurrentHashSet();
//
// /**
// * 配置中的Key加载模式,默认加载所有属性
// */
// private KeyLoadingMode keyLoadingMode = KeyLoadingMode.ALL;
//
// /**
// * 节点下属性的加载模式
// */
// public static enum KeyLoadingMode {
//
// /**
// * 加载所有属性
// */
// ALL,
// /**
// * 加载指定的属性
// */
// INCLUDE,
// /**
// * 排除指定的属性
// */
// EXCLUDE;
// }
//
// }
| import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.apache.curator.utils.ZKPaths;
import com.github.config.api.ConfigProfile; | package com.github.config.group;
/**
* Zookeeper配置剖面
*
* @author ZhangWei
*/
@Setter
@Getter
@ToString
@NoArgsConstructor | // Path: elastic-config-core/src/main/java/com/github/config/api/ConfigProfile.java
// @Setter
// @Getter
// @NoArgsConstructor
// public abstract class ConfigProfile {
//
// public ConfigProfile(String rootNode, String version) {
// super();
// this.version = version;
// this.rootNode = rootNode;
// }
//
// /**
// * 配置结点
// */
// protected String node;
//
// /**
// * 项目根结点
// */
// protected String rootNode;
//
// /**
// * 项目配置版本
// */
// protected String version;
//
// /**
// * 本地配置文件
// */
// protected Multimap<String, File> filemultimap;
//
// /**
// * 需要包含或排除的key
// */
// private Set<String> keysSpecified = Sets.newConcurrentHashSet();
//
// /**
// * 配置中的Key加载模式,默认加载所有属性
// */
// private KeyLoadingMode keyLoadingMode = KeyLoadingMode.ALL;
//
// /**
// * 节点下属性的加载模式
// */
// public static enum KeyLoadingMode {
//
// /**
// * 加载所有属性
// */
// ALL,
// /**
// * 加载指定的属性
// */
// INCLUDE,
// /**
// * 排除指定的属性
// */
// EXCLUDE;
// }
//
// }
// Path: elastic-config-core/src/main/java/com/github/config/group/ZookeeperConfigProfile.java
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.apache.curator.utils.ZKPaths;
import com.github.config.api.ConfigProfile;
package com.github.config.group;
/**
* Zookeeper配置剖面
*
* @author ZhangWei
*/
@Setter
@Getter
@ToString
@NoArgsConstructor | public class ZookeeperConfigProfile extends ConfigProfile { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.